HList-0.2.3: Heterogeneous lists

Data.HList.Variant

Description

The HList library

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

Variants, i.e., labelled sums.

One approach to their implementation would be to consider both the favoured label and the corresponding value as dynamics upon variant construction. Since we are too lazy to programme some Typeable instances for non-ghc systems (NB: in GHC, Typeable is derivable), we rather model variants as (opaque) records with maybies for the values. Only one value will actually hold non-Nothing, as guaranteed by the constructor.

See VariantP.hs for a different approach to open sums.

Synopsis

Documentation

newtype Variant mr Source

Variant types on the basis of label-maybe pairs.

Constructors

Variant mr 

Instances

Show (Variant v)

Variants are opaque

class HMaybied r r' | r -> r' whereSource

Turn proxy sequence into sequence of Nothings

Methods

hMaybied :: r -> r'Source

Instances

HMaybied HNil HNil 
HMaybied r r' => HMaybied (HCons (LVPair l (Proxy v)) r) (HCons (LVPair l (Maybe v)) r') 

mkVariant :: (RecordLabels v ls, HFind x ls n, HMaybied v v', HUpdateAtHNat n (LVPair x (Maybe y)) v' v') => x -> y -> Record v -> Variant v'Source

Public constructor

unVariant :: (RecordLabels v ls, HFind x ls n, HLookupByHNat n v (LVPair x (Maybe y))) => x -> Variant v -> Maybe ySource

Public destructor