|
|
|
|
|
| Description |
| This module contains a datatype Field and sone type classes. It is used
to construct record-like datatypes.
|
|
| Synopsis |
|
|
|
| Documentation |
|
Example:
To create a "record" with the accessors/modificators first you have to define the type
of the record, It must be a right-associative list of pairs, just like a LISP list.
The rightmost element must be () . The following Example defines a record with information
for music generation.
type DefaultNote = (Int, (Double, (Char, ())))
Then a default value should be defined.
defaultNote = (0, (1.0, ('a' , ())))
defaultNote :: DefaultNote
For each "datafield" the Field must be declared.
pitch :: Field DefaultNote Int
volume :: Field DefaultNote Double
channel :: Field DefaultNote Char
Creating the fields is done with toField applied to a value of the "record" type.
pitch :>> volume :>> channel :>> NilM = toFields defaultNote
Is is recommended to declare all types and match all results of toFields incl. the NilM at
the end.
NOTE:
pitch :>> volume :>> channel :>> NilM = toFields (undefined :: DefaultNote)
should work too.
|
|
| Field
|
|
|
| A Field record field is an interface to access a type field which
is part of a type record .
A Field is used to access and modify subtypes ("datafields") of
a record-like datastructure. In this module, a right-associative pair structure is
taken as record-type with "datafields" in the fst parts of the pairs.
| | Constructors | | Field | | | getField :: c -> a | | | setField :: (a -> a) -> c -> c | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Constructors | | Group | | | isGroup :: c -> Maybe a | | | mkGroup :: a -> c | |
|
|
|
|
|
|
|
|
|
|
| Hetero List
|
|
|
| Constructors | | Instances | |
|
|
|
| The correct type is: data NilM (m :: * -> *) = NilM .
(But Haddock rejects this definition. GHC will need it)
data NilM m = NilM
| | Constructors | | Instances | |
|
|
| class PushFields m where | Source |
|
| | Methods | | | Instances | |
|
|
| class ToFields a r where | Source |
|
| | Methods | | | Instances | |
|
|
| class PushGroups m where | Source |
|
| | Methods | | | Instances | |
|
|
| class ToGroups a r where | Source |
|
| | Methods | | | Instances | |
|
|
| Produced by Haddock version 2.4.2 |