base-4.6.0.1: Basic libraries

Safe HaskellTrustworthy

GHC.Generics

Contents

Synopsis

Generic representation types

data V1 p

Void: used for datatypes without constructors

data U1 p

Unit: used for constructors without arguments

Constructors

U1 

newtype Par1 p

Used for marking occurrences of the parameter

Constructors

Par1 

Fields

unPar1 :: p
 

newtype Rec1 f p

Recursive calls of kind * -> *

Constructors

Rec1 

Fields

unRec1 :: f p
 

newtype K1 i c p

Constants, additional parameters and recursion of kind *

Constructors

K1 

Fields

unK1 :: c
 

newtype M1 i c f p

Meta-information (constructor names, etc.)

Constructors

M1 

Fields

unM1 :: f p
 

data (f :+: g) p

Sums: encode choice between constructors

Constructors

L1 (f p) 
R1 (g p) 

data (f :*: g) p

Products: encode multiple arguments to constructors

Constructors

(f p) :*: (g p) 

newtype (f :.: g) p

Composition of functors

Constructors

Comp1 

Fields

unComp1 :: f (g p)
 

Synonyms for convenience

type Rec0 = K1 R

Type synonym for encoding recursion (of kind *)

type Par0 = K1 P

Deprecated: Par0 is no longer used; use Rec0 instead

Type synonym for encoding parameters (other than the last)

data R

Tag for K1: recursion (of kind *)

data P

Deprecated: P is no longer used; use R instead

Tag for K1: parameters (other than the last)

type D1 = M1 D

Type synonym for encoding meta-information for datatypes

type C1 = M1 C

Type synonym for encoding meta-information for constructors

type S1 = M1 S

Type synonym for encoding meta-information for record selectors

data D

Tag for M1: datatype

data C

Tag for M1: constructor

data S

Tag for M1: record selector

Meta-information

class Datatype d where

Class for datatypes that represent datatypes

Methods

datatypeName :: t d (f :: * -> *) a -> [Char]

The name of the datatype (unqualified)

moduleName :: t d (f :: * -> *) a -> [Char]

The fully-qualified name of the module where the type is declared

class Constructor c where

Class for datatypes that represent data constructors

Methods

conName :: t c (f :: * -> *) a -> [Char]

The name of the constructor

conFixity :: t c (f :: * -> *) a -> Fixity

The fixity of the constructor

conIsRecord :: t c (f :: * -> *) a -> Bool

Marks if this constructor is a record

class Selector s where

Class for datatypes that represent records

Methods

selName :: t s (f :: * -> *) a -> [Char]

The name of the selector

Instances

data NoSelector

Used for constructor fields without a name

Instances

data Fixity

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

Datatype to represent the associativity of a constructor

data Arity

Datatype to represent the arity of a tuple.

Constructors

NoArity 
Arity Int 

prec :: Fixity -> Int

Get the precedence of a fixity value.

Generic type classes

class Generic a where

Representable types of kind *. This class is derivable in GHC with the DeriveGeneric flag on.

Associated Types

type Rep a :: * -> *

Generic representation type

Methods

from :: a -> Rep a x

Convert from the datatype to its representation

to :: Rep a x -> a

Convert from the representation to the datatype

Instances

Generic Bool 
Generic Char 
Generic Double 
Generic Float 
Generic Int 
Generic Ordering 
Generic () 
Generic [a] 
Generic (Maybe a) 
Generic (Either a b) 
Generic (a, b) 
Generic (a, b, c) 
Generic (a, b, c, d) 
Generic (a, b, c, d, e) 
Generic (a, b, c, d, e, f) 
Generic (a, b, c, d, e, f, g) 

class Generic1 f where

Representable types of kind * -> *. This class is derivable in GHC with the DeriveGeneric flag on.

Associated Types

type Rep1 f :: * -> *

Generic representation type

Methods

from1 :: f a -> Rep1 f a

Convert from the datatype to its representation

to1 :: Rep1 f a -> f a

Convert from the representation to the datatype

Instances

Generic1 [] 
Generic1 Maybe 
Generic1 (Either a) 
Generic1 ((,) a) 
Generic1 ((,,) a b) 
Generic1 ((,,,) a b c) 
Generic1 ((,,,,) a b c d) 
Generic1 ((,,,,,) a b c d e) 
Generic1 ((,,,,,,) a b c d e f)