Safe Haskell | Safe |
---|---|
Language | Haskell98 |
Data.Record
- class Kind kind where
- class Sort kind sort where
- class Kind (K style) => Style style where
- type family Value style sort :: *
- class Kind kind => Record kind record where
- newtype ExtenderPiece thing record name sort = ExtenderPiece (thing record -> thing (record :& (name ::: sort)))
- data X style = X
- data (record :& field) style = !(record style) :& !(field style)
- data (name ::: sort) style = !name := (Value style sort)
- type family Cat (record1 :: * -> *) (record2 :: * -> *) :: * -> *
- cat :: (Style style, Record (K style) record1, Record (K style) record2) => record1 style -> record2 style -> Cat record1 record2 style
- map :: (Style style, Style style', K style ~ K style', Record (K style) record) => Forall (K style) (TransformerPiece style style') -> record style -> record style'
- newtype TransformerPiece style style' sort = TransformerPiece (Value style sort -> Value style' sort)
- class Subrecord subrecord record where
Kinds
class Sort kind sort where Source #
Minimal complete definition
Methods
specialize :: Forall kind piece -> piece sort Source #
Styles
class Kind (K style) => Style style Source #
Instances
Style PlainStyle Source # | |
Style (ConnectorStyle connector) Source # | |
Style (SignalStyle era) Source # | |
Style style => Style (ContextStyle context style) Source # | |
???
type family Value style sort :: * Source #
Instances
type Value PlainStyle val Source # | |
type Value (ConnectorStyle connector) (Of signal val) Source # | |
type Value (SignalStyle era) (Of signal val) Source # | |
type Value (ContextStyle context style) sort Source # | |
Records
class Kind kind => Record kind record where Source #
The class of all record types.
A record type is a type of records without the style parameter. Therefore, it has kind * ->
*
.
Minimal complete definition
Methods
build :: thing X -> (forall record name. Record kind record => Forall kind (ExtenderPiece thing record name)) -> thing record Source #
A general method for building record-related “things”.
For each record type, this method constructs a value which is somehow related to this
record type. Such a value is called a thing. The type parameter thing
maps record
types to the types of their corresponding things. The first argument of build
gives
the thing of the empty record type while the second argument tells how to transform a
thing of an arbitrary record type into the thing of this record type extended
with an arbitrary field type.
build
is used, for example, to implement the function cat
.
newtype ExtenderPiece thing record name sort Source #
Constructors
ExtenderPiece (thing record -> thing (record :& (name ::: sort))) |
The type of empty records.
Constructors
X |
data (record :& field) style infixl 2 Source #
The type of non-empty records, consisting of an initial record and a last field.
Constructors
!(record style) :& !(field style) infixl 2 |
Instances
(Kind kind, Record kind record, Sort kind sort) => Record kind ((:&) record ((:::) name sort)) Source # | |
OptRecord optRecord => OptRecord ((:&) optRecord ((:::) (Opt name) sort)) Source # | |
OptRecord optRecord => OptRecord ((:&) optRecord ((:::) (Req name) sort)) Source # | |
(Dissection record remainder subname subsort, Subrecord subrecord remainder) => Subrecord ((:&) subrecord ((:::) subname subsort)) record Source # | |
(Show (init style), Show (last style)) => Show ((:&) init last style) Source # | |
type Cat record1 ((:&) record2 field2) Source # | |
type All ((:&) optRecord ((:::) (Opt name) sort)) Source # | |
type All ((:&) optRecord ((:::) (Req name) sort)) Source # | |
type Required ((:&) optRecord ((:::) (Opt name) sort)) Source # | |
type Required ((:&) optRecord ((:::) (Req name) sort)) Source # | |
data (name ::: sort) style infix 3 Source #
The family of record fields.
Each instance of it matches arbitrary name
parameters and all signalOfVal
parameters
which are of the form signal `
. The actual choice of the instance
depends only on the Of
` valstyle
parameter. The structure of fields of a specific style is
documented together with the respective style type.
Instances
(Kind kind, Record kind record, Sort kind sort) => Record kind ((:&) record ((:::) name sort)) Source # | |
OptRecord optRecord => OptRecord ((:&) optRecord ((:::) (Opt name) sort)) Source # | |
OptRecord optRecord => OptRecord ((:&) optRecord ((:::) (Req name) sort)) Source # | |
(Dissection record remainder subname subsort, Subrecord subrecord remainder) => Subrecord ((:&) subrecord ((:::) subname subsort)) record Source # | |
(Show name, Show (Value style sort)) => Show ((:::) name sort style) Source # | |
type All ((:&) optRecord ((:::) (Opt name) sort)) Source # | |
type All ((:&) optRecord ((:::) (Req name) sort)) Source # | |
type Required ((:&) optRecord ((:::) (Opt name) sort)) Source # | |
type Required ((:&) optRecord ((:::) (Req name) sort)) Source # | |
Catenation
type family Cat (record1 :: * -> *) (record2 :: * -> *) :: * -> * Source #
The catenation of two record types.
cat :: (Style style, Record (K style) record1, Record (K style) record2) => record1 style -> record2 style -> Cat record1 record2 style Source #
The catenation of two records.
Mapping
map :: (Style style, Style style', K style ~ K style', Record (K style) record) => Forall (K style) (TransformerPiece style style') -> record style -> record style' Source #
Application of a function to the fields of a record.
newtype TransformerPiece style style' sort Source #
Constructors
TransformerPiece (Value style sort -> Value style' sort) |
Subrecords
class Subrecord subrecord record where Source #
The class of all pairs of record types where the first is a subrecord of the second.
Currenty, the subrecord relation is only defined for records which do not have multiple occurences of the same name. A records is a subrecord of another record if all field types of the first record are also field types of the second, independently of order.
The instance declarations of Subrecord
use several helper classes which are hidden. One of
them is the class Presence
. You get the error message that no instance of Presence
name
could be found if the alleged subrecord contains a name which is not present in the
alleged superrecord.
Minimal complete definition