Copyright | (c) 2010, Universiteit Utrecht |
---|---|
License | BSD3 |
Maintainer | generics@haskell.org |
Stability | experimental |
Portability | non-portable |
Safe Haskell | Safe-Inferred |
Language | Haskell98 |
Generics.Instant.Base
Description
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'
Documentation
Constructors
U |
Instances
(Read a, Read b) => Read ((:+:) a b) | |
(Show a, Show b) => Show ((:+:) a b) | |
(Representable a, Representable b) => Representable ((:+:) a b) | |
(HasRec a, HasRec b) => HasRec ((:+:) a b) | |
(HasRec a, Empty a, Empty b) => Empty ((:+:) a b) | |
(GEnum f, GEnum g) => GEnum ((:+:) f g) | |
type Rep ((:+:) a b) = (:+:) a b |
Constructors
a :*: b infixr 6 |
Instances
Instances
Constructors
Var a |
Constructors
Rec a |
class Constructor c where Source
Class for datatypes that represent data constructors.
For non-symbolic constructors, only conName
has to be defined.
Minimal complete definition
Datatype to represent the fixity of a constructor. An infix declaration
directly corresponds to an application of Infix
.
Constructors
Prefix | |
Infix Associativity Int |
data Associativity Source
Datatype to represent the associativy of a constructor.
Constructors
LeftAssociative | |
RightAssociative | |
NotAssociative |
class Representable a where Source
Instances
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) |