Safe Haskell | None |
---|---|
Language | Haskell2010 |
Derive
generics-sop
boilerplate instances from GHC's
Generic
.
The technique being used here is described in the following paper:
- José Pedro Magalhães and Andres Löh. Generic Generic Programming . Practical Aspects of Declarative Languages (PADL) 2014.
Synopsis
- type GCode (a :: Type ) = ToSumCode ( Rep a) '[]
- type GFrom a = GSumFrom ( Rep a)
- type GTo a = GSumTo ( Rep a)
- type GDatatypeInfo a = DemoteDatatypeInfo ( GDatatypeInfoOf a) ( GCode a)
- type GDatatypeInfoOf (a :: Type ) = ToInfo ( Rep a)
- gfrom :: ( GFrom a, Generic a) => a -> SOP I ( GCode a)
- gto :: forall a. ( GTo a, Generic a) => SOP I ( GCode a) -> a
- gdatatypeInfo :: forall proxy a. GDatatypeInfo a => proxy a -> DatatypeInfo ( GCode a)
Documentation
type GCode (a :: Type ) = ToSumCode ( Rep a) '[] Source #
Compute the SOP code of a datatype.
This requires that
Rep
is defined, which in turn requires that
the type has a
Generic
(from module
GHC.Generics
) instance.
This is the default definition for
Code
.
For more info, see
Generic
.
type GDatatypeInfo a = DemoteDatatypeInfo ( GDatatypeInfoOf a) ( GCode a) Source #
Constraint for the class that computes
gdatatypeInfo
.
type GDatatypeInfoOf (a :: Type ) = ToInfo ( Rep a) Source #
Compute the datatype info of a datatype.
Since: 0.3.0.0
gfrom :: ( GFrom a, Generic a) => a -> SOP I ( GCode a) Source #
An automatically computed version of
from
.
This requires that the type being converted has a
Generic
(from module
GHC.Generics
) instance.
This is the default definition for
from
.
For more info, see
Generic
.
gto :: forall a. ( GTo a, Generic a) => SOP I ( GCode a) -> a Source #
An automatically computed version of
to
.
This requires that the type being converted has a
Generic
(from module
GHC.Generics
) instance.
This is the default definition for
to
.
For more info, see
Generic
.
gdatatypeInfo :: forall proxy a. GDatatypeInfo a => proxy a -> DatatypeInfo ( GCode a) Source #
An automatically computed version of
datatypeInfo
.
This requires that the type being converted has a
Generic
(from module
GHC.Generics
) instance.
This is the default definition for
datatypeInfo
.
For more info, see
HasDatatypeInfo
.