HList-0.2.3: Heterogeneous lists

Data.HList.GhcSyntax

Contents

Description

(C) 2004, Oleg Kiselyov, Ralf Laemmel, Keean Schupke

Some dedicated infix operators at the type and the value level.

Synopsis

For types

type :*: e l = HCons e lSource

type :=: l v = LVPair l vSource

For records

(.*.) :: HExtend e l l' => e -> l -> l'Source

(.*.)
Add a field to a record. Analagous to (++) for lists.
 record .*. field1
        .*. field2

(.=.) :: l -> v -> LVPair l vSource

Create a value with the given label. Analagous to a data constructor such as Just, Left, or Right. Higher fixity than record-modification operations like (.*.), (.-.), etc. to support expression like the below w/o parentheses:

 label1 .=. value1 .*.
 label2 .=. value2 .*.
 emptyRecord

(.!.) :: HasField l r v => r -> l -> vSource

Lookup a value in a record, by its label. Analagous to (!!), the list indexing operation. Highest fixity, like (!!).

 record1 .*. label1 .=. record2 .!. label1
         .*. label2 .=. record2 .!. label2

(.-.) :: H2ProjectByLabels (HCons e HNil) r _r' r' => Record r -> e -> Record r'Source

Remove a field from a record. At the same level as other record modification options (.*.). Analagous to (\) in lists.

 record1 .-. label1
 label1 .=. value1 .*.
 label2 .=. value2 .-.
 label2 .*.
 emptyRecord
 label1 .=. value1 .-.
 label1 .*.
 label2 .=. value2 .*.
 emptyRecord
 record1 .*. label1 .=. record2 .!. label1
         .*. label2 .=. record2 .!. label2
         .-. label1

(.@.) :: (HUpdateAtHNat n (LVPair t t1) t2 l', HFind t ls n, RecordLabels t2 ls) => LVPair t t1 -> Record t2 -> Record l'Source

Update a field with a particular value. Same fixity as (.*.) so that extensions and updates can be chained. There is no real list analogue, since there is no Prelude defined update.

 label1 .=. value1 .@. record1

(.^.) :: (HUpdateAtHNat n (LVPair t t1) t2 l', HFind t ls n, RecordLabels t2 ls, HasField t t2 (Proxy t1)) => LVPair t t1 -> Record t2 -> Record l'Source

This is a variation on updating (according to GhcRecord.hs), so use the same fixity as (.@.).

(.<.) :: (HasField t t2 t1, HUpdateAtHNat n (LVPair t t1) t2 l', HFind t ls n, RecordLabels t2 ls) => LVPair t t1 -> Record t2 -> Record l'Source

Another variation on update, so give it the same fixity as (.@.).

(.<++.) :: HLeftUnion r r' r'' => r -> r' -> r''Source

Similar to list append, so give this slightly lower fixity than (.*.), so we can write:

 field1 .=. value .*. record1 .<++. record2

type :+: e l = HCons (Proxy e) lSource

(.+.) :: HExtend (Proxy e) l l' => e -> l -> l'Source

Type-indexed rows append. Very similar to (.*.), so keep the same fixity.