Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Data.MultiGenerics
Description
Multirec-style generics, indexed by data kind k
.
Pattern functors should have kind (k -> *) -> k -> *
.
- newtype Fix f ix = Fix {}
- data family Sing a
- class SingI a where
- class ShowM f where
- class EqM f where
- type GenM f = forall ix. Sing ix -> Gen (f ix)
- class ArbitraryM f where
- arbitraryM :: GenM f
- class Generic1m f where
- data V1m p ix
- data U1m p ix = U1m
- newtype Par1m xi p ix = Par1m {
- unPar1m :: p xi
- newtype Rec1m f xi p ix = Rec1m {
- unRec1m :: f (p xi)
- newtype K1m i c p ix = K1m {
- unK1m :: c
- data (f :++: g) p ix
- data (f :**: g) p ix = (f p ix) :**: (g p ix)
- data Tag1m f xi p ix where
Documentation
Multirec-style fix-point, indexed by data kind.
The singleton kind-indexed data family. Taken from the singletons
package.
A SingI
constraint is essentially an implicitly-passed singleton.
Methods
Produce the singleton explicitly. You will likely need the ScopedTypeVariables
extension to use this method the way you want.
Convert a pattern functor to a readable String
.
We have equality for each instantiation of the pattern functor.
class ArbitraryM f where Source
Methods
arbitraryM :: GenM f Source
Instances
ArbitraryM Ty (Fix Ty Bis) |
class Generic1m f where Source
Representable types of kind * -> *. This class is derivable in GHC with the DeriveGeneric flag on.
Methods
from1k :: f a ix -> Rep1m f a ix Source
Convert from the datatype to its representation.
to1k :: Rep1m f a ix -> f a ix Source
Convert from the representation to the datatype.
Instances
Generic1m Ty Bis | Implementation of |
Generic1m k (Par1m k xi) | |
Generic1m k (U1m (k -> *) k) | |
Generic1m k (V1m (k -> *) k) | |
Generic1m k f => Generic1m k (Tag1m k f xi) | |
(Generic1m k f, Generic1m k g) => Generic1m k ((:++:) k f g) | |
Generic1m k (Rec1m k f xi) | |
(Generic1m k f, Generic1m k g) => Generic1m k ((:**:) (k -> *) k f g) | |
Generic1m k (K1m k (k -> *) k i c) |
Void: used for datatypes without constructors.
Unit: used for constructors without arguments.
Constructors
U1m |
Used for marking occurrences of the parameter.
Constants, additional parameters and recursion of kind *
.
data (f :++: g) p ix infixr 5 Source
Sums: encode choice between constructors.
Instances
(Generic1m k f, Generic1m k g) => Generic1m k ((:++:) k f g) | |
(Eq (f p ix), Eq (g p ix)) => Eq ((:++:) k f g p ix) | |
(Ord (f p ix), Ord (g p ix)) => Ord ((:++:) k f g p ix) | |
(Read (f p ix), Read (g p ix)) => Read ((:++:) k f g p ix) | |
(Show (f p ix), Show (g p ix)) => Show ((:++:) k f g p ix) | |
type Rep1m k ((:++:) k f g) = (:++:) k f g |
data (f :**: g) p ix infixr 6 Source
Products: encode multiple arguments to constructors.
Constructors
(f p ix) :**: (g p ix) infixr 6 |
Instances
(Generic1m k f, Generic1m k g) => Generic1m k ((:**:) (k -> *) k f g) | |
(Eq (f p ix), Eq (g p ix)) => Eq ((:**:) k k f g p ix) | |
(Ord (f p ix), Ord (g p ix)) => Ord ((:**:) k k f g p ix) | |
(Read (f p ix), Read (g p ix)) => Read ((:**:) k k f g p ix) | |
(Show (f p ix), Show (g p ix)) => Show ((:**:) k k f g p ix) | |
type Rep1m k ((:**:) (k -> *) k f g) = (:**:) (k -> *) k f g |