Safe Haskell | None |
---|---|

Language | Haskell2010 |

Derive `generics-sop`

boilerplate instances from GHC's `GHC.Generic`

.

- type GCode a = ToSumCode (GHC.Rep a) []
- type GFrom a = GSumFrom (GHC.Rep a)
- type GTo a = GSumTo (GHC.Rep a)
- type GDatatypeInfo a = GDatatypeInfo' (GHC.Rep a)
- gfrom :: (GFrom a, GHC.Generic a) => a -> SOP I (GCode a)
- gto :: forall a. (GTo a, GHC.Generic a) => SOP I (GCode a) -> a
- gdatatypeInfo :: forall a. GDatatypeInfo a => Proxy a -> DatatypeInfo (GCode a)

# Documentation

type GCode a = ToSumCode (GHC.Rep a) [] Source

Compute the SOP code of a datatype.

This requires that `GHC.Rep`

is defined, which in turn requires that
the type has a `GHC.Generic`

(from module GHC.Generics) instance.

This is the default definition for `Code`

.
For more info, see `Generic`

.

type GDatatypeInfo a = GDatatypeInfo' (GHC.Rep a) Source

Constraint for the class that computes `gdatatypeInfo`

.

gfrom :: (GFrom a, GHC.Generic a) => a -> SOP I (GCode a) Source

An automatically computed version of `from`

.

This requires that the type being converted has a
`GHC.Generic`

(from module GHC.Generics) instance.

This is the default definition for `from`

.
For more info, see `Generic`

.

gto :: forall a. (GTo a, GHC.Generic a) => SOP I (GCode a) -> a Source

An automatically computed version of `to`

.

This requires that the type being converted has a
`GHC.Generic`

(from module GHC.Generics) instance.

This is the default definition for `to`

.
For more info, see `Generic`

.

gdatatypeInfo :: forall a. GDatatypeInfo a => Proxy a -> DatatypeInfo (GCode a) Source

An automatically computed version of `datatypeInfo`

.

This requires that the type being converted has a
`GHC.Generic`

(from module GHC.Generics) instance.

This is the default definition for `datatypeInfo`

.
For more info, see `HasDatatypeInfo`

.