emgm-0.3.1: Extensible and Modular Generics for the MassesSource codeContentsIndex
Generics.EMGM.Common.Base
Portabilitynon-portable
Stabilityexperimental
Maintainergenerics@haskell.org
Contents
Generic function class
Representation dispatcher classes
Description

Summary: Type classes used for generic functions with one generic argument.

Generic functions using one generic argument are defined as instances of Generic. This class contains all of the methods (called "type cases" in datatype-generic language) used to define the run-time type representation of a datatype.

To simplify generic functions, we use type classes for representation dispatching. There are "dispatchers" for each category of function (see below) and each category has one "Rep" class.

Some Generic-based functions operate on monomorphic values (using Rep). The functions included with the library are:

Other Generic-based functions operate on types of the form f a (using FRep) where f is the actual generic argument (the one that needs a run-time representation). The functions included with the library are:

Synopsis
class Generic g where
rconstant :: (Enum a, Eq a, Ord a, Read a, Show a) => g a
rint :: g Int
rinteger :: g Integer
rfloat :: g Float
rdouble :: g Double
rchar :: g Char
runit :: g Unit
rsum :: g a -> g b -> g (a :+: b)
rprod :: g a -> g b -> g (a :*: b)
rcon :: ConDescr -> g a -> g a
rtype :: EP b a -> g a -> g b
class Rep g a where
rep :: g a
class FRep g f where
frep :: g a -> g (f a)
Generic function class
class Generic g whereSource
This class forms the foundation for defining generic functions with a single generic argument. Each method represents a type case. The class includes cases for primitive types, cases for the structural representation, and the rtype case for adding support for new datatypes.
Methods
rconstant :: (Enum a, Eq a, Ord a, Read a, Show a) => g aSource

Many functions perform the same operation on the non-structural cases (as well as Unit). The cases for constant datatypes (Int, Integer, Float, Double, Char, and Unit) have a default implementation of rconstant, thus a generic function may only override rconstant if desired. Note that there is no default implementation for rconstant itself.

The class context represents the intersection set of supported type classes.

rint :: g IntSource
Case for the primitive type Int. (Default implementation: rconstant.)
rinteger :: g IntegerSource
Case for the primitive type Integer. (Default implementation: rconstant.)
rfloat :: g FloatSource
Case for the primitive type Float. (Default implementation: rconstant.)
rdouble :: g DoubleSource
Case for the primitive type Double. (Default implementation: rconstant.)
rchar :: g CharSource
Case for the primitive type Char. (Default implementation: rconstant.)
runit :: g UnitSource
Case for the structural representation type Unit. It is used to represent a constructor with no arguments. (Default implementation: rconstant.)
rsum :: g a -> g b -> g (a :+: b)Source
Case for the structural representation type :+: (sum). It is used to represent alternative choices between constructors. (No default implementation.)
rprod :: g a -> g b -> g (a :*: b)Source
Case for the structural representation type :*: (product). It is used to represent multiple arguments to a constructor. (No default implementation.)
rcon :: ConDescr -> g a -> g aSource
Case for constructors. While not necessary for every generic function, this method is required for Read and Show. It is used to hold the meta-information about a constructor (ConDescr), e.g. name, arity, fixity, etc. (Since most generic functions do not use rcon and simply pass the value through, the default implementation is const id.)
rtype :: EP b a -> g a -> g bSource
Case for datatypes. This method is used to define the structural representation of an arbitrary Haskell datatype. The first argument is the embedding-projection pair, necessary for establishing the isomorphism between datatype and representation. The second argument is the run-time representation using the methods of Generic. (No default implementation.)
show/hide Instances
Representation dispatcher classes
class Rep g a whereSource
The Generic representation dispatcher for monomorphic types (kind *). Every structure type and supported datatype should have an instance of Rep. (No default implementation.)
Methods
rep :: g aSource
show/hide Instances
Generic g => Rep g Unit
Generic g => Rep g Char
Generic g => Rep g Double
Generic g => Rep g Float
Generic g => Rep g Integer
Generic g => Rep g Int
Generic g => Rep g Bool
Generic g => Rep g ()
Rep Read String
Rep Read String
Rep Read ()
Rep Read ()
Rep Show String
Rep Show String
Rep Show ()
Rep Show ()
(Generic g, Rep g a) => Rep g ([] a)
(Generic g, Rep g a) => Rep g (Maybe a)
Rep Read a => Rep Read ([] a)
Rep Read a => Rep Read ([] a)
Rep Show a => Rep Show ([] a)
Rep Show a => Rep Show ([] a)
(Generic g, Rep g a, Rep g b) => Rep g (a :*: b)
(Generic g, Rep g a, Rep g b) => Rep g (a :+: b)
(Generic g, Rep g a, Rep g b) => Rep g (Either a b)
(Generic g, Rep g a, Rep g b) => Rep g ((,) a b)
(Rep Read a, Rep Read b) => Rep Read ((,) a b)
(Rep Read a, Rep Read b) => Rep Read ((,) a b)
(Rep Show a, Rep Show b) => Rep Show ((,) a b)
(Rep Show a, Rep Show b) => Rep Show ((,) a b)
(Generic g, Rep g a, Rep g b, Rep g c) => Rep g ((,,) a b c)
(Rep Read a, Rep Read b, Rep Read c) => Rep Read ((,,) a b c)
(Rep Read a, Rep Read b, Rep Read c) => Rep Read ((,,) a b c)
(Rep Show a, Rep Show b, Rep Show c) => Rep Show ((,,) a b c)
(Rep Show a, Rep Show b, Rep Show c) => Rep Show ((,,) a b c)
(Generic g, Rep g a, Rep g b, Rep g c, Rep g d) => Rep g ((,,,) a b c d)
(Rep Read a, Rep Read b, Rep Read c, Rep Read d) => Rep Read ((,,,) a b c d)
(Rep Read a, Rep Read b, Rep Read c, Rep Read d) => Rep Read ((,,,) a b c d)
(Rep Show a, Rep Show b, Rep Show c, Rep Show d) => Rep Show ((,,,) a b c d)
(Rep Show a, Rep Show b, Rep Show c, Rep Show d) => Rep Show ((,,,) a b c d)
(Generic g, Rep g a, Rep g b, Rep g c, Rep g d, Rep g e) => Rep g ((,,,,) a b c d e)
(Rep Read a, Rep Read b, Rep Read c, Rep Read d, Rep Read e) => Rep Read ((,,,,) a b c d e)
(Rep Read a, Rep Read b, Rep Read c, Rep Read d, Rep Read e) => Rep Read ((,,,,) a b c d e)
(Rep Show a, Rep Show b, Rep Show c, Rep Show d, Rep Show e) => Rep Show ((,,,,) a b c d e)
(Rep Show a, Rep Show b, Rep Show c, Rep Show d, Rep Show e) => Rep Show ((,,,,) a b c d e)
(Generic g, Rep g a, Rep g b, Rep g c, Rep g d, Rep g e, Rep g f) => Rep g ((,,,,,) a b c d e f)
(Rep Read a, Rep Read b, Rep Read c, Rep Read d, Rep Read e, Rep Read f) => Rep Read ((,,,,,) a b c d e f)
(Rep Read a, Rep Read b, Rep Read c, Rep Read d, Rep Read e, Rep Read f) => Rep Read ((,,,,,) a b c d e f)
(Rep Show a, Rep Show b, Rep Show c, Rep Show d, Rep Show e, Rep Show f) => Rep Show ((,,,,,) a b c d e f)
(Rep Show a, Rep Show b, Rep Show c, Rep Show d, Rep Show e, Rep Show f) => Rep Show ((,,,,,) a b c d e f)
(Generic g, Rep g a, Rep g b, Rep g c, Rep g d, Rep g e, Rep g f, Rep g h) => Rep g ((,,,,,,) a b c d e f h)
(Rep Read a, Rep Read b, Rep Read c, Rep Read d, Rep Read e, Rep Read f, Rep Read h) => Rep Read ((,,,,,,) a b c d e f h)
(Rep Read a, Rep Read b, Rep Read c, Rep Read d, Rep Read e, Rep Read f, Rep Read h) => Rep Read ((,,,,,,) a b c d e f h)
(Rep Show a, Rep Show b, Rep Show c, Rep Show d, Rep Show e, Rep Show f, Rep Show h) => Rep Show ((,,,,,,) a b c d e f h)
(Rep Show a, Rep Show b, Rep Show c, Rep Show d, Rep Show e, Rep Show f, Rep Show h) => Rep Show ((,,,,,,) a b c d e f h)
Rep (Collect Bool) Bool
Rep (Collect Bool) Bool
Rep (Collect Char) Char
Rep (Collect Char) Char
Rep (Collect Double) Double
Rep (Collect Double) Double
Rep (Collect Float) Float
Rep (Collect Float) Float
Rep (Collect Int) Int
Rep (Collect Int) Int
Rep (Collect Integer) Integer
Rep (Collect Integer) Integer
Rep (Collect ()) ()
Rep (Collect ()) ()
Rep (Everywhere' Bool) Bool
Rep (Everywhere' Bool) Bool
Rep (Everywhere' Char) Char
Rep (Everywhere' Char) Char
Rep (Everywhere' Double) Double
Rep (Everywhere' Double) Double
Rep (Everywhere' Float) Float
Rep (Everywhere' Float) Float
Rep (Everywhere' Int) Int
Rep (Everywhere' Int) Int
Rep (Everywhere' Integer) Integer
Rep (Everywhere' Integer) Integer
Rep (Everywhere' ()) ()
Rep (Everywhere' ()) ()
Rep (Everywhere Bool) Bool
Rep (Everywhere Bool) Bool
Rep (Everywhere Char) Char
Rep (Everywhere Char) Char
Rep (Everywhere Double) Double
Rep (Everywhere Double) Double
Rep (Everywhere Float) Float
Rep (Everywhere Float) Float
Rep (Everywhere Int) Int
Rep (Everywhere Int) Int
Rep (Everywhere Integer) Integer
Rep (Everywhere Integer) Integer
Rep (Everywhere ()) ()
Rep (Everywhere ()) ()
Rep (Collect ([] a)) ([] a)
Rep (Collect ([] a)) ([] a)
Rep (Collect (Maybe a)) (Maybe a)
Rep (Collect (Maybe a)) (Maybe a)
Rep (Everywhere' ([] a)) ([] a)
Rep (Everywhere' ([] a)) ([] a)
Rep (Everywhere' (Maybe a)) (Maybe a)
Rep (Everywhere' (Maybe a)) (Maybe a)
Rep (Everywhere ([] a)) a => Rep (Everywhere ([] a)) ([] a)
Rep (Everywhere ([] a)) a => Rep (Everywhere ([] a)) ([] a)
Rep (Everywhere (Maybe a)) a => Rep (Everywhere (Maybe a)) (Maybe a)
Rep (Everywhere (Maybe a)) a => Rep (Everywhere (Maybe a)) (Maybe a)
Rep (Collect (Either a b)) (Either a b)
Rep (Collect (Either a b)) (Either a b)
Rep (Collect ((,) a b)) ((,) a b)
Rep (Collect ((,) a b)) ((,) a b)
Rep (Everywhere' (Either a b)) (Either a b)
Rep (Everywhere' (Either a b)) (Either a b)
Rep (Everywhere' ((,) a b)) ((,) a b)
Rep (Everywhere' ((,) a b)) ((,) a b)
(Rep (Everywhere (Either a b)) a, Rep (Everywhere (Either a b)) b) => Rep (Everywhere (Either a b)) (Either a b)
(Rep (Everywhere (Either a b)) a, Rep (Everywhere (Either a b)) b) => Rep (Everywhere (Either a b)) (Either a b)
(Rep (Everywhere ((,) a b)) a, Rep (Everywhere ((,) a b)) b) => Rep (Everywhere ((,) a b)) ((,) a b)
(Rep (Everywhere ((,) a b)) a, Rep (Everywhere ((,) a b)) b) => Rep (Everywhere ((,) a b)) ((,) a b)
Rep (Collect ((,,) a b c)) ((,,) a b c)
Rep (Collect ((,,) a b c)) ((,,) a b c)
Rep (Everywhere' ((,,) a b c)) ((,,) a b c)
Rep (Everywhere' ((,,) a b c)) ((,,) a b c)
(Rep (Everywhere ((,,) a b c)) a, Rep (Everywhere ((,,) a b c)) b, Rep (Everywhere ((,,) a b c)) c) => Rep (Everywhere ((,,) a b c)) ((,,) a b c)
(Rep (Everywhere ((,,) a b c)) a, Rep (Everywhere ((,,) a b c)) b, Rep (Everywhere ((,,) a b c)) c) => Rep (Everywhere ((,,) a b c)) ((,,) a b c)
Rep (Collect ((,,,) a b c d)) ((,,,) a b c d)
Rep (Collect ((,,,) a b c d)) ((,,,) a b c d)
Rep (Everywhere' ((,,,) a b c d)) ((,,,) a b c d)
Rep (Everywhere' ((,,,) a b c d)) ((,,,) a b c d)
(Rep (Everywhere ((,,,) a b c d)) a, Rep (Everywhere ((,,,) a b c d)) b, Rep (Everywhere ((,,,) a b c d)) c, Rep (Everywhere ((,,,) a b c d)) d) => Rep (Everywhere ((,,,) a b c d)) ((,,,) a b c d)
(Rep (Everywhere ((,,,) a b c d)) a, Rep (Everywhere ((,,,) a b c d)) b, Rep (Everywhere ((,,,) a b c d)) c, Rep (Everywhere ((,,,) a b c d)) d) => Rep (Everywhere ((,,,) a b c d)) ((,,,) a b c d)
Rep (Collect ((,,,,) a b c d e)) ((,,,,) a b c d e)
Rep (Collect ((,,,,) a b c d e)) ((,,,,) a b c d e)
Rep (Everywhere' ((,,,,) a b c d e)) ((,,,,) a b c d e)
Rep (Everywhere' ((,,,,) a b c d e)) ((,,,,) a b c d e)
(Rep (Everywhere ((,,,,) a b c d e)) a, Rep (Everywhere ((,,,,) a b c d e)) b, Rep (Everywhere ((,,,,) a b c d e)) c, Rep (Everywhere ((,,,,) a b c d e)) d, Rep (Everywhere ((,,,,) a b c d e)) e) => Rep (Everywhere ((,,,,) a b c d e)) ((,,,,) a b c d e)
(Rep (Everywhere ((,,,,) a b c d e)) a, Rep (Everywhere ((,,,,) a b c d e)) b, Rep (Everywhere ((,,,,) a b c d e)) c, Rep (Everywhere ((,,,,) a b c d e)) d, Rep (Everywhere ((,,,,) a b c d e)) e) => Rep (Everywhere ((,,,,) a b c d e)) ((,,,,) a b c d e)
Rep (Collect ((,,,,,) a b c d e f)) ((,,,,,) a b c d e f)
Rep (Collect ((,,,,,) a b c d e f)) ((,,,,,) a b c d e f)
Rep (Everywhere' ((,,,,,) a b c d e f)) ((,,,,,) a b c d e f)
Rep (Everywhere' ((,,,,,) a b c d e f)) ((,,,,,) a b c d e f)
(Rep (Everywhere ((,,,,,) a b c d e f)) a, Rep (Everywhere ((,,,,,) a b c d e f)) b, Rep (Everywhere ((,,,,,) a b c d e f)) c, Rep (Everywhere ((,,,,,) a b c d e f)) d, Rep (Everywhere ((,,,,,) a b c d e f)) e, Rep (Everywhere ((,,,,,) a b c d e f)) f) => Rep (Everywhere ((,,,,,) a b c d e f)) ((,,,,,) a b c d e f)
(Rep (Everywhere ((,,,,,) a b c d e f)) a, Rep (Everywhere ((,,,,,) a b c d e f)) b, Rep (Everywhere ((,,,,,) a b c d e f)) c, Rep (Everywhere ((,,,,,) a b c d e f)) d, Rep (Everywhere ((,,,,,) a b c d e f)) e, Rep (Everywhere ((,,,,,) a b c d e f)) f) => Rep (Everywhere ((,,,,,) a b c d e f)) ((,,,,,) a b c d e f)
Rep (Collect ((,,,,,,) a b c d e f h)) ((,,,,,,) a b c d e f h)
Rep (Collect ((,,,,,,) a b c d e f h)) ((,,,,,,) a b c d e f h)
Rep (Everywhere' ((,,,,,,) a b c d e f h)) ((,,,,,,) a b c d e f h)
Rep (Everywhere' ((,,,,,,) a b c d e f h)) ((,,,,,,) a b c d e f h)
(Rep (Everywhere ((,,,,,,) a b c d e f h)) a, Rep (Everywhere ((,,,,,,) a b c d e f h)) b, Rep (Everywhere ((,,,,,,) a b c d e f h)) c, Rep (Everywhere ((,,,,,,) a b c d e f h)) d, Rep (Everywhere ((,,,,,,) a b c d e f h)) e, Rep (Everywhere ((,,,,,,) a b c d e f h)) f, Rep (Everywhere ((,,,,,,) a b c d e f h)) h) => Rep (Everywhere ((,,,,,,) a b c d e f h)) ((,,,,,,) a b c d e f h)
(Rep (Everywhere ((,,,,,,) a b c d e f h)) a, Rep (Everywhere ((,,,,,,) a b c d e f h)) b, Rep (Everywhere ((,,,,,,) a b c d e f h)) c, Rep (Everywhere ((,,,,,,) a b c d e f h)) d, Rep (Everywhere ((,,,,,,) a b c d e f h)) e, Rep (Everywhere ((,,,,,,) a b c d e f h)) f, Rep (Everywhere ((,,,,,,) a b c d e f h)) h) => Rep (Everywhere ((,,,,,,) a b c d e f h)) ((,,,,,,) a b c d e f h)
class FRep g f whereSource
The Generic representation dispatcher for functor types (kind * -> *), sometimes called container types. (No default implementation.)
Methods
frep :: g a -> g (f a)Source
show/hide Instances
Generic g => FRep g []
Generic g => FRep g Maybe
Produced by Haddock version 2.4.2