Skip to content

Commit

Permalink
Update haddock for PlutusType class
Browse files Browse the repository at this point in the history
  • Loading branch information
srid committed Jan 26, 2022
1 parent 3141797 commit 28a8a4c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Plutarch/PlutusType.hs
Expand Up @@ -38,7 +38,20 @@ import Plutarch.PLam ((#))
The 'PlutusType' class allows encoding Haskell data-types as plutus terms
via constructors and destructors.
A simple example, encoding a Sum type as an Enum via PInteger:
Typically, you want to use scott encoding to represent the data type, which
can be automatically derived as follows:
> import qualified GHC.Generics as GHC
> import Generics.SOP
>
> data MyType (a :: PType) (b :: PType) (s :: S)
> = One (Term s a)
> | Two (Term s b)
> deriving stock (GHC.Generic)
> deriving anyclass (Generic, PlutusType)
Alternative, you may derive it by hand as well. A simple example, encoding a
Sum type as an Enum via PInteger:
> data AB (s :: S) = A | B
>
Expand Down

0 comments on commit 28a8a4c

Please sign in to comment.