Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | generics@haskell.org |
Safe Haskell | Safe-Inferred |
This module defines the basic representation types and the conversion
functions to
and from
. A typical instance for a user-defined datatype
would be:
-- Example datatype data Exp = Const Int | Plus Exp Exp -- Auxiliary datatypes for constructor representations data Const data Plus instance Constructor Const where conName _ = "Const" instance Constructor Plus where conName _ = "Plus" -- Representable instance instance Representable Exp where type Rep Exp = C Const (Var Int) :+: C Plus (Rec Exp :*: Rec Exp) from (Const n) = L (C (Var n)) from (Plus e e') = R (C (Rec e :*: Rec e')) to (L (C (Var n))) = Const n to (R (C (Rec e :*: Rec e'))) = Plus e e'
- data Z
- data U = U
- data a :+: b
- data a :*: b = a :*: b
- data CEq c p q a where
- type C c a = CEq c () () a
- data Var a = Var a
- data Rec a = Rec a
- class Constructor c where
- conName :: t c p q a -> String
- conFixity :: t c p q a -> Fixity
- conIsRecord :: t c p q a -> Bool
- data Fixity
- = Prefix
- | Infix Associativity Int
- data Associativity
- class Representable a where
- type family X c n a :: k2
- data Nat
Documentation
a :*: b |
Var a |
Rec a |
class Constructor c whereSource
Class for datatypes that represent data constructors.
For non-symbolic constructors, only conName
has to be defined.
Datatype to represent the fixity of a constructor. An infix declaration
directly corresponds to an application of Infix
.
Prefix | |
Infix Associativity Int |
data Associativity Source
Datatype to represent the associativy of a constructor.
Eq Associativity | |
Ord Associativity | |
Read Associativity | |
Show Associativity | |
Lift Associativity |
class Representable a whereSource
Representable Bool | |
Representable Char | |
Representable Float | |
Representable Int | |
Representable U | |
Representable [a] | |
Representable (Maybe a) | |
Representable a => Representable (Rec a) | |
Representable a => Representable (Var a) | |
Representable (a, b) | |
(Representable a, Representable b) => Representable (:*: a b) | |
(Representable a, Representable b) => Representable (:+: a b) | |
Representable a => Representable (CEq * * c p q a) |