regular-0.2: Generic programming library for regular datatypes.Source codeContentsIndex
Generics.Regular.Base
Portabilitynon-portable
Stabilityexperimental
Maintainergenerics@haskell.org
Contents
Functorial structural representation types
Fixed-point type
Type class capturing the structural representation of a type and the corresponding embedding-projection pairs
Description
Summary: Types for structural representation.
Synopsis
data K a r = K {
unK :: a
}
data I r = I {
unI :: r
}
data U r = U
data (f :+: g) r
= L (f r)
| R (g r)
data (f :*: g) r = (f r) :*: (g r)
data C c f r = C {
unC :: f r
}
data S l f r = S {
unS :: f r
}
class Constructor c where
conName :: t c (f :: * -> *) r -> String
conFixity :: t c (f :: * -> *) r -> Fixity
conIsRecord :: t c (f :: * -> *) r -> Bool
data Fixity
= Prefix
| Infix Associativity Int
data Associativity
= LeftAssociative
| RightAssociative
| NotAssociative
class Selector s where
selName :: t s (f :: * -> *) r -> String
newtype Fix f = In {
out :: f (Fix f)
}
class Regular a where
from :: a -> PF a a
to :: PF a a -> a
type family PF a :: * -> *
Functorial structural representation types
data K a r Source
Structure type for constant values.
Constructors
K
unK :: a
show/hide Instances
Functor (K a)
ConNames (K a)
Crush (K a)
Eq a => Eq (K a)
Unfold (K a)
Fold (K a)
GMap (K a)
LRBase a => LR (K a)
Read a => Read (K a)
CountAtoms (K a)
DeepSeq a => Seq (K a)
Show a => Show (K a)
Eq a => Zip (K a)
data I r Source
Structure type for recursive values.
Constructors
I
unI :: r
show/hide Instances
data U r Source
Structure type for empty constructors.
Constructors
U
show/hide Instances
data (f :+: g) r Source
Structure type for alternatives in a type.
Constructors
L (f r)
R (g r)
show/hide Instances
(Functor f, Functor g) => Functor (f :+: g)
(ConNames f, ConNames g) => ConNames (f :+: g)
(Crush f, Crush g) => Crush (f :+: g)
(Eq f, Eq g) => Eq (f :+: g)
(Unfold f, Unfold g) => Unfold (f :+: g)
(Fold f, Fold g) => Fold (f :+: g)
(GMap f, GMap g) => GMap (f :+: g)
(LR f, LR g) => LR (f :+: g)
(Read f, Read g) => Read (f :+: g)
(Seq f, Seq g) => Seq (f :+: g)
(Show f, Show g) => Show (f :+: g)
(Zip f, Zip g) => Zip (f :+: g)
data (f :*: g) r Source
Structure type for fields of a constructor.
Constructors
(f r) :*: (g r)
show/hide Instances
(Functor f, Functor g) => Functor (f :*: g)
(ConNames f, ConNames g) => ConNames (f :*: g)
(Crush f, Crush g) => Crush (f :*: g)
(Eq f, Eq g) => Eq (f :*: g)
(Unfold f, Unfold g) => Unfold (f :*: g)
Fold g => Fold (I :*: g)
Fold g => Fold (K a :*: g)
(GMap f, GMap g) => GMap (f :*: g)
(LR f, LR g) => LR (f :*: g)
(Read f, Read g) => Read (f :*: g)
(CountAtoms f, CountAtoms g) => CountAtoms (f :*: g)
(Seq f, Seq g) => Seq (f :*: g)
(Show f, Show g) => Show (f :*: g)
(Zip f, Zip g) => Zip (f :*: g)
data C c f r Source
Structure type to store the name of a constructor.
Constructors
C
unC :: f r
show/hide Instances
Functor f => Functor (C c f)
(ConNames f, Constructor c) => ConNames (C c f)
Crush f => Crush (C c f)
Eq f => Eq (C c f)
Unfold f => Unfold (C c f)
Fold f => Fold (C c f)
GMap f => GMap (C c f)
LR f => LR (C c f)
(Constructor c, CountAtoms (f :*: g), Read f, Read g) => Read (C c (f :*: g))
(Constructor c, Read (S s f)) => Read (C c (S s f))
(Constructor c, Read (K a)) => Read (C c (K a))
(Constructor c, Read I) => Read (C c I)
Constructor c => Read (C c U)
Seq f => Seq (C c f)
(Constructor c, Show f) => Show (C c f)
Zip f => Zip (C c f)
data S l f r Source
Structure type to store the name of a record selector.
Constructors
S
unS :: f r
show/hide Instances
Functor f => Functor (S c f)
Crush f => Crush (S s f)
Unfold f => Unfold (S s f)
Fold f => Fold (S s f)
GMap f => GMap (S s f)
LR f => LR (S s f)
(Selector s, Read f) => Read (S s f)
CountAtoms f => CountAtoms (S s f)
Seq f => Seq (S s f)
(Selector s, Show f) => Show (S s f)
Zip f => Zip (S s f)
class Constructor c whereSource
Class for datatypes that represent data constructors. For non-symbolic constructors, only conName has to be defined. The weird argument is supposed to be instantiated with C from base, hence the complex kind.
Methods
conName :: t c (f :: * -> *) r -> StringSource
conFixity :: t c (f :: * -> *) r -> FixitySource
conIsRecord :: t c (f :: * -> *) r -> BoolSource
data Fixity Source
Datatype to represent the fixity of a constructor. An infix declaration directly corresponds to an application of Infix.
Constructors
Prefix
Infix Associativity Int
show/hide Instances
data Associativity Source
Constructors
LeftAssociative
RightAssociative
NotAssociative
show/hide Instances
class Selector s whereSource
Methods
selName :: t s (f :: * -> *) r -> StringSource
Fixed-point type
newtype Fix f Source
The well-known fixed-point type.
Constructors
In
out :: f (Fix f)
Type class capturing the structural representation of a type and the corresponding embedding-projection pairs
class Regular a whereSource

The type class Regular captures the structural representation of a type and the corresponding embedding-projection pairs.

To be able to use the generic functions, the user is required to provide an instance of this type class.

Methods
from :: a -> PF a aSource
to :: PF a a -> aSource
type family PF a :: * -> *Source

The type family PF represents the pattern functor of a datatype.

To be able to use the generic functions, the user is required to provide an instance of this type family.

Produced by Haddock version 2.4.2