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

Summary: Type classes used for generic functions with three generic arguments.

Generic functions using three generic arguments are defined as instances of Generic3. 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.

Generic3-based functions have a non-extensible representation dispatcher type class, FRep3.

The functions included with the library are:

Synopsis
class Generic3 g where
rconstant3 :: (Enum a, Eq a, Ord a, Read a, Show a) => g a a a
rint3 :: g Int Int Int
rinteger3 :: g Integer Integer Integer
rfloat3 :: g Float Float Float
rdouble3 :: g Double Double Double
rchar3 :: g Char Char Char
runit3 :: g Unit Unit Unit
rsum3 :: g a1 a2 a3 -> g b1 b2 b3 -> g (a1 :+: b1) (a2 :+: b2) (a3 :+: b3)
rprod3 :: g a1 a2 a3 -> g b1 b2 b3 -> g (a1 :*: b1) (a2 :*: b2) (a3 :*: b3)
rcon3 :: ConDescr -> g a1 a2 a3 -> g a1 a2 a3
rtype3 :: EP a2 a1 -> EP b2 b1 -> EP c2 c1 -> g a1 b1 c1 -> g a2 b2 c2
class FRep3 g f where
frep3 :: g a b c -> g (f a) (f b) (f c)
Generic function class
class Generic3 g whereSource
This class forms the foundation for defining generic functions with three generic arguments. 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
rconstant3 :: (Enum a, Eq a, Ord a, Read a, Show a) => g a a 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 rconstant3, thus a generic function may only override rconstant3 if desired. Note that there is no default implementation for rconstant3 itself.

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

rint3 :: g Int Int IntSource
Case for the primitive type Int. (Default implementation: rconstant3.)
rinteger3 :: g Integer Integer IntegerSource
Case for the primitive type Integer. (Default implementation: rconstant3.)
rfloat3 :: g Float Float FloatSource
Case for the primitive type Float. (Default implementation: rconstant3.)
rdouble3 :: g Double Double DoubleSource
Case for the primitive type Double. (Default implementation: rconstant3.)
rchar3 :: g Char Char CharSource
Case for the primitive type Char. (Default implementation: rconstant3.)
runit3 :: g Unit Unit UnitSource
Case for the structural representation type Unit. It is used to represent a constructor with no arguments. (Default implementation: rconstant3.)
rsum3 :: g a1 a2 a3 -> g b1 b2 b3 -> g (a1 :+: b1) (a2 :+: b2) (a3 :+: b3)Source
Case for the structural representation type :+: (sum). It is used to represent alternative choices between constructors. (No default implementation.)
rprod3 :: g a1 a2 a3 -> g b1 b2 b3 -> g (a1 :*: b1) (a2 :*: b2) (a3 :*: b3)Source
Case for the structural representation type :*: (product). It is used to represent multiple arguments to a constructor. (No default implementation.)
rcon3 :: ConDescr -> g a1 a2 a3 -> g a1 a2 a3Source
Case for constructors. 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.)
rtype3 :: EP a2 a1 -> EP b2 b1 -> EP c2 c1 -> g a1 b1 c1 -> g a2 b2 c2Source
Case for datatypes. This method is used to define the structural representation of an arbitrary Haskell datatype. The first three arguments are the embedding-projection pairs, necessary for establishing the isomorphisms between datatype and representation of the four generic types. The fourth argument is the run-time representation using the methods of Generic3. (No default implementation.)
show/hide Instances
Representation dispatcher classes
class FRep3 g f whereSource
The Generic3 representation dispatcher for functor types (kind * -> *), sometimes called container types. (No default implementation.)
Methods
frep3 :: g a b c -> g (f a) (f b) (f c)Source
show/hide Instances
Produced by Haddock version 2.4.2