HList-0.2.3: Heterogeneous lists

Data.HList.Label3

Description

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 obviously can be automated with Template Haskell.

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.

Synopsis

Documentation

data Label x ns desc Source

Labels are type-level naturals

Instances

(HNat x, Show desc) => Show (Label x ns desc) 
(HNat x, Show desc) => ShowLabel (Label x ns desc)

Show label

(HEq x x' b, TypeEq ns ns' b', HAnd b b' b'') => HEq (Label x ns desc) (Label x' ns' desc') b''

Equality on labels (descriptions are ignored)

firstLabel :: ns -> desc -> Label HZero ns descSource

Construct the first label

nextLabel :: Label x ns desc -> desc' -> Label (HSucc x) ns desc'Source

Construct the next label