base-4.7.0.0: Basic libraries

Copyright(c) Universiteit Utrecht 2010-2011, University of Oxford 2012
License(c) Universiteit Utrecht 2010-2011, University of Oxford 2012
Maintainerlibraries@haskell.org
Stabilityinternal
Portabilitynon-portable
Safe HaskellTrustworthy

GHC.Generics

Contents

Description

Support for generic programming with a sum-of-products view. For more information, please visit the HaskellWiki page (http://www.haskell.org/haskellwiki/GHC.Generics) or use the generic-deriving package on Hackage: http://hackage.haskell.org/package/generic-deriving.

Synopsis

Generic representation types

data V1 p Source

Void: used for datatypes without constructors

data U1 p Source

Unit: used for constructors without arguments

Constructors

U1 

Instances

Eq (U1 p) 
Read (U1 p) 
Show (U1 p) 
Generic (U1 p) 

newtype Par1 p Source

Used for marking occurrences of the parameter

Constructors

Par1 

Fields

unPar1 :: p
 

Instances

Eq p => Eq (Par1 p) 
Read p => Read (Par1 p) 
Show p => Show (Par1 p) 
Generic (Par1 p) 

newtype Rec1 f p Source

Recursive calls of kind * -> *

Constructors

Rec1 

Fields

unRec1 :: f p
 

Instances

Eq (f p) => Eq (Rec1 f p) 
Read (f p) => Read (Rec1 f p) 
Show (f p) => Show (Rec1 f p) 
Generic (Rec1 f p) 

newtype K1 i c p Source

Constants, additional parameters and recursion of kind *

Constructors

K1 

Fields

unK1 :: c
 

Instances

Eq c => Eq (K1 i c p) 
Read c => Read (K1 i c p) 
Show c => Show (K1 i c p) 
Generic (K1 i c p) 

newtype M1 i c f p Source

Meta-information (constructor names, etc.)

Constructors

M1 

Fields

unM1 :: f p
 

Instances

Eq (f p) => Eq (M1 i c f p) 
Read (f p) => Read (M1 i c f p) 
Show (f p) => Show (M1 i c f p) 
Generic (M1 i c f p) 

data (f :+: g) p Source

Sums: encode choice between constructors

Constructors

L1 (f p) 
R1 (g p) 

Instances

(Eq (f p), Eq (g p)) => Eq (:+: f g p) 
(Read (f p), Read (g p)) => Read (:+: f g p) 
(Show (f p), Show (g p)) => Show (:+: f g p) 
Generic (:+: f g p) 

data (f :*: g) p Source

Products: encode multiple arguments to constructors

Constructors

(f p) :*: (g p) 

Instances

(Eq (f p), Eq (g p)) => Eq (:*: f g p) 
(Read (f p), Read (g p)) => Read (:*: f g p) 
(Show (f p), Show (g p)) => Show (:*: f g p) 
Generic (:*: f g p) 

newtype (f :.: g) p Source

Composition of functors

Constructors

Comp1 

Fields

unComp1 :: f (g p)
 

Instances

Eq (f (g p)) => Eq (:.: f g p) 
Read (f (g p)) => Read (:.: f g p) 
Show (f (g p)) => Show (:.: f g p) 
Generic (:.: f g p) 

Synonyms for convenience

type Rec0 = K1 RSource

Type synonym for encoding recursion (of kind *)

type Par0 = K1 PSource

Deprecated: Par0 is no longer used; use Rec0 instead

Type synonym for encoding parameters (other than the last)

data R Source

Tag for K1: recursion (of kind *)

data P Source

Deprecated: P is no longer used; use R instead

Tag for K1: parameters (other than the last)

type D1 = M1 DSource

Type synonym for encoding meta-information for datatypes

type C1 = M1 CSource

Type synonym for encoding meta-information for constructors

type S1 = M1 SSource

Type synonym for encoding meta-information for record selectors

data D Source

Tag for M1: datatype

data C Source

Tag for M1: constructor

data S Source

Tag for M1: record selector

Meta-information

class Datatype d whereSource

Class for datatypes that represent datatypes

Methods

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

The name of the datatype (unqualified)

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

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

isNewtype :: t d (f :: * -> *) a -> BoolSource

Marks if the datatype is actually a newtype

class Constructor c whereSource

Class for datatypes that represent data constructors

Methods

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

The name of the constructor

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

The fixity of the constructor

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

Marks if this constructor is a record

class Selector s whereSource

Class for datatypes that represent records

Methods

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

The name of the selector

Instances

data NoSelector Source

Used for constructor fields without a name

Instances

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 

data Associativity Source

Datatype to represent the associativity of a constructor

data Arity Source

Datatype to represent the arity of a tuple.

Constructors

NoArity 
Arity Int 

prec :: Fixity -> IntSource

Get the precedence of a fixity value.

Generic type classes

class Generic a whereSource

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

Associated Types

type Rep a :: * -> *Source

Generic representation type

Methods

from :: a -> Rep a xSource

Convert from the datatype to its representation

to :: Rep a x -> aSource

Convert from the representation to the datatype

Instances

Generic Bool 
Generic Char 
Generic Double 
Generic Float 
Generic Int 
Generic Ordering 
Generic () 
Generic Associativity 
Generic Fixity 
Generic Arity 
Generic [a] 
Generic (U1 p) 
Generic (Par1 p) 
Generic (Maybe a) 
Generic (Either a b) 
Generic (Rec1 f p) 
Generic (a, b) 
Generic (Proxy * t) 
Generic (K1 i c p) 
Generic (:+: f g p) 
Generic (:*: f g p) 
Generic (:.: f g p) 
Generic (a, b, c) 
Generic (M1 i c f p) 
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 whereSource

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

Associated Types

type Rep1 f :: * -> *Source

Generic representation type

Methods

from1 :: f a -> Rep1 f aSource

Convert from the datatype to its representation

to1 :: Rep1 f a -> f aSource

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)