Safe Haskell | None |
---|---|
Language | Haskell2010 |
The HList library
(C) 2004-2006, Oleg Kiselyov, Ralf Laemmel, Keean Schupke
A model of labels as needed for extensible records. As before, all the information about labels is recorded in their type, so the labels of records may be purely phantom. In general, Labels are exclusively type-level entities and have no run-time representation.
Record labels are triplets of type-level naturals, namespace, and description. The namespace part helps avoid confusions between labels from different Haskell modules. The description is an arbitrary nullary type constructor.
For the sake of printing, the description is required to be the instance of Show. One must make sure that the show functions does not examine the value, as descr is purely phantom. Here's an example of the good Label description:
data MyLabelDescr; instance Show MyLabelDescr where show _ = "descr"
which are automated by makeLabels3 from Data.HList.MakeLabel.
This model even allows the labels in a record to belong to different namespaces. To this end, the model employs the predicate for type equality.
Documentation
>>>
let label3 = Label :: Label (Lbl HZero () ())
>>>
let label6 = Label :: Label "6"
data Lbl (x :: HNat) (ns :: *) (desc :: *) Source #
(HEqBy * HNat HLeFn n m b, (~) * ns ns') => HEqBy * * HLeFn (Lbl n ns desc) (Lbl m ns' desc') b Source # | Data.HList.Label3 labels can only be compared if they belong to the same namespace. |
(~) * (Label k t) (Label * (Lbl ix ns n)) => SameLabels * * (Label k t) (Lbl ix ns n) Source # | |
Show desc => ShowLabel * (Lbl x ns desc) Source # | Equality on labels (descriptions are ignored) Use generic instance Show label |
Show desc => Show (Label * (Lbl x ns desc)) Source # | |
HExtend (Label * (Lbl n ns desc)) (Proxy [Symbol] ((:) Symbol x xs)) Source # | Mixing two label kinds means we have to include
|
HExtend (Label * (Lbl n ns desc)) (Proxy [*] ((:) * (Lbl n' ns' desc') xs)) Source # | If possible, Label is left off:
|
type ZipTagged * ((:) * (Lbl ix ns n) ts) ((:) * v vs) Source # | |
type HExtendR (to p q) (Proxy [*] ((:) * (Lbl n ns desc) xs)) Source # | |
type HExtendR (Label * (Lbl n ns desc)) (Proxy [*] ((:) * (Lbl n' ns' desc') xs)) Source # | |
type HExtendR (Label * (Lbl n ns desc)) (Proxy [Symbol] ((:) Symbol x xs)) Source # | |
Public constructors for labels
nextLabel :: Label (Lbl x ns desc) -> desc' -> Label (Lbl (HSucc x) ns desc') Source #
Construct the next label
type family MapLabel (xs :: [k]) :: [*] Source #
similar to Data.HList.Record.Labels1, but avoids producing Label (Label x)
Orphan instances
HExtend (Label Nat y) (Proxy [Symbol] ((:) Symbol x xs)) Source # | |
HExtend (Label Nat y) (Proxy [*] ((:) * x xs)) Source # | |
HExtend (Label Symbol y) (Proxy [Nat] ((:) Nat x xs)) Source # | |
HExtend (Label Symbol y) (Proxy [*] ((:) * x xs)) Source # | Mixing two label kinds means we have to include
|