HList-0.5.1.0: Heterogeneous lists
Safe HaskellNone
LanguageHaskell2010

Data.HList.HListPrelude

Description

The HList library

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

Declarations for various classes and functions that apply for the whole range of heterogeneous collections (HList, TIP, records, etc).

Synopsis

Documentation

class HExtend e l where Source #

Associated Types

type HExtendR e l Source #

Methods

(.*.) :: e -> l -> HExtendR e l infixr 2 Source #

Instances

Instances details
HExtend e (HList l) Source # 
Instance details

Defined in Data.HList.HList

Associated Types

type HExtendR e (HList l) Source #

Methods

(.*.) :: e -> HList l -> HExtendR e (HList l) Source #

HRLabelSet (t ': r) => HExtend t (Record r) Source # 
Instance details

Defined in Data.HList.Record

Associated Types

type HExtendR t (Record r) Source #

Methods

(.*.) :: t -> Record r -> HExtendR t (Record r) Source #

(le ~ Tagged l (Maybe e), HOccursNot (Label l) (LabelsOf v)) => HExtend le (Variant v) Source #

Extension for Variants prefers the first value

(l .=. Nothing) .*. v = v
(l .=. Just e)  .*. _ = mkVariant l e Proxy
Instance details

Defined in Data.HList.Variant

Associated Types

type HExtendR le (Variant v) Source #

Methods

(.*.) :: le -> Variant v -> HExtendR le (Variant v) Source #

(HRLabelSet (Tagged e e ': l), HTypeIndexed l) => HExtend e (TIP l) Source # 
Instance details

Defined in Data.HList.TIP

Associated Types

type HExtendR e (TIP l) Source #

Methods

(.*.) :: e -> TIP l -> HExtendR e (TIP l) Source #

(me ~ Maybe e, HOccursNot (Tagged e e) l) => HExtend me (TIC l) Source #
Nothing .*. x = x
Just a .*. y = mkTIC a
Instance details

Defined in Data.HList.TIC

Associated Types

type HExtendR me (TIC l) Source #

Methods

(.*.) :: me -> TIC l -> HExtendR me (TIC l) Source #

(to ~ LabeledTo x, ToSym (to p q) x) => HExtend (to p q) (Proxy (Lbl n ns desc ': xs)) Source #

if the proxy has Data.HList.Label3.Lbl, then everything has to be wrapped in Label to make the kinds match up.

Instance details

Defined in Data.HList.Labelable

Associated Types

type HExtendR (to p q) (Proxy (Lbl n ns desc ': xs)) Source #

Methods

(.*.) :: to p q -> Proxy (Lbl n ns desc ': xs) -> HExtendR (to p q) (Proxy (Lbl n ns desc ': xs)) Source #

(to ~ LabeledTo x, ToSym (to p q) x) => HExtend (to p q) (Proxy (x ': xs)) Source # 
Instance details

Defined in Data.HList.Labelable

Associated Types

type HExtendR (to p q) (Proxy (x ': xs)) Source #

Methods

(.*.) :: to p q -> Proxy (x ': xs) -> HExtendR (to p q) (Proxy (x ': xs)) Source #

(to ~ LabeledTo x, ToSym (to p q) x) => HExtend (to p q) (Proxy ('[] :: [Type])) Source #

Together with the instance below, this allows writing

makeLabelable "x y z"
p = x .*. y .*. z .*. emptyProxy

Or with HListPP

p = `x .*. `y .*. `z .*. emptyProxy

instead of

p = Proxy :: Proxy ["x","y","z"]
Instance details

Defined in Data.HList.Labelable

Associated Types

type HExtendR (to p q) (Proxy '[]) Source #

Methods

(.*.) :: to p q -> Proxy '[] -> HExtendR (to p q) (Proxy '[]) Source #

HExtend (Label (Lbl n ns desc)) (Proxy (x ': xs)) Source #

Mixing two label kinds means we have to include Label:

>>> let r = label3 .*. label6 .*. emptyProxy
>>> :t r
r :: Proxy '[Label (Lbl 'HZero () ()), Label "6"]
Instance details

Defined in Data.HList.Label3

Associated Types

type HExtendR (Label (Lbl n ns desc)) (Proxy (x ': xs)) Source #

Methods

(.*.) :: Label (Lbl n ns desc) -> Proxy (x ': xs) -> HExtendR (Label (Lbl n ns desc)) (Proxy (x ': xs)) Source #

HExtend (Label (Lbl n ns desc)) (Proxy (Lbl n' ns' desc' ': xs)) Source #

If possible, Label is left off:

>>> let q = label3 .*. label3 .*. emptyProxy
>>> :t q
q :: Proxy '[Lbl 'HZero () (), Lbl 'HZero () ()]
Instance details

Defined in Data.HList.Label3

Associated Types

type HExtendR (Label (Lbl n ns desc)) (Proxy (Lbl n' ns' desc' ': xs)) Source #

Methods

(.*.) :: Label (Lbl n ns desc) -> Proxy (Lbl n' ns' desc' ': xs) -> HExtendR (Label (Lbl n ns desc)) (Proxy (Lbl n' ns' desc' ': xs)) Source #

HExtend (Label y) (Proxy (x ': xs)) Source # 
Instance details

Defined in Data.HList.Label3

Associated Types

type HExtendR (Label y) (Proxy (x ': xs)) Source #

Methods

(.*.) :: Label y -> Proxy (x ': xs) -> HExtendR (Label y) (Proxy (x ': xs)) Source #

HExtend (Label y) (Proxy (x ': xs)) Source # 
Instance details

Defined in Data.HList.Label3

Associated Types

type HExtendR (Label y) (Proxy (x ': xs)) Source #

Methods

(.*.) :: Label y -> Proxy (x ': xs) -> HExtendR (Label y) (Proxy (x ': xs)) Source #

HExtend (Label y) (Proxy (x ': xs)) Source # 
Instance details

Defined in Data.HList.Label6

Associated Types

type HExtendR (Label y) (Proxy (x ': xs)) Source #

Methods

(.*.) :: Label y -> Proxy (x ': xs) -> HExtendR (Label y) (Proxy (x ': xs)) Source #

HExtend (Label y) (Proxy (x ': xs)) Source # 
Instance details

Defined in Data.HList.Label3

Associated Types

type HExtendR (Label y) (Proxy (x ': xs)) Source #

Methods

(.*.) :: Label y -> Proxy (x ': xs) -> HExtendR (Label y) (Proxy (x ': xs)) Source #

HExtend (Label y) (Proxy (x ': xs)) Source #

Mixing two label kinds means we have to include Label:

>>> let s = label6 .*. label3 .*. emptyProxy
>>> :t s
s :: Proxy '[Label "6", Label (Lbl 'HZero () ())]
Instance details

Defined in Data.HList.Label3

Associated Types

type HExtendR (Label y) (Proxy (x ': xs)) Source #

Methods

(.*.) :: Label y -> Proxy (x ': xs) -> HExtendR (Label y) (Proxy (x ': xs)) Source #

HExtend (Label y) (Proxy (x ': xs)) Source #
>>> let labelX = Label :: Label "x"
>>> let labelY = Label :: Label "y"
>>> let p = labelX .*. labelY .*. emptyProxy
>>> :t p
p :: Proxy '["x", "y"]
Instance details

Defined in Data.HList.Label6

Associated Types

type HExtendR (Label y) (Proxy (x ': xs)) Source #

Methods

(.*.) :: Label y -> Proxy (x ': xs) -> HExtendR (Label y) (Proxy (x ': xs)) Source #

HExtend (Label x) (Proxy ('[] :: [Type])) Source #

to keep types shorter, .*. used with Proxy avoids producing a Proxy :: Proxy '[Label x,Label y,Label z] if Proxy :: Proxy '[x,y,z] is not a kind error (as it is when mixing Label6 and Label3 labels).

ghc-7.6 does not accept Proxy ('[] :: [k]) so for now require k ~ *

Instance details

Defined in Data.HList.HListPrelude

Associated Types

type HExtendR (Label x) (Proxy '[]) Source #

Methods

(.*.) :: Label x -> Proxy '[] -> HExtendR (Label x) (Proxy '[]) Source #

emptyProxy :: Proxy ('[] :: [Type]) Source #

similar to emptyRecord, emptyTIP, emptyHList (actually called HNil), except emptyProxy is the rightmost argument to .*.

class SubType l l' Source #

Instances

Instances details
H2ProjectByLabels (LabelsOf r2) r1 r2 rout => SubType (Record r1 :: Type) (Record r2 :: Type) Source #

Subtyping for records

Instance details

Defined in Data.HList.Record

(HOccurs e (TIP l1), SubType (TIP l1) (TIP l2)) => SubType (TIP l1 :: Type) (TIP (e ': l2) :: Type) Source # 
Instance details

Defined in Data.HList.TIP

SubType (TIP l :: Type) (TIP ('[] :: [Type])) Source #

Subtyping for TIPs

Instance details

Defined in Data.HList.TIP

class HAppend l1 l2 where Source #

Methods

hAppend :: l1 -> l2 -> HAppendR l1 l2 Source #

Instances

Instances details
HAppendList l1 l2 => HAppend (HList l1) (HList l2) Source # 
Instance details

Defined in Data.HList.HList

Methods

hAppend :: HList l1 -> HList l2 -> HAppendR (HList l1) (HList l2) Source #

(HRLabelSet (HAppendListR r1 r2), HAppend (HList r1) (HList r2)) => HAppend (Record r1) (Record r2) Source #
(.*.)
Add a field to a record. Analagous to (++) for lists.
record .*. field1
       .*. field2
Instance details

Defined in Data.HList.Record

Methods

hAppend :: Record r1 -> Record r2 -> HAppendR (Record r1) (Record r2) Source #

(HAppend (HList l) (HList l'), HTypeIndexed (HAppendListR l l')) => HAppend (TIP l) (TIP l') Source # 
Instance details

Defined in Data.HList.TIP

Methods

hAppend :: TIP l -> TIP l' -> HAppendR (TIP l) (TIP l') Source #

type family HAppendR (l1 :: k) (l2 :: k) :: k Source #

poly-kinded, but hAppend only works in cases where the kind variable k is *

Instances

Instances details
type HAppendR (HList l1 :: Type) (HList l2 :: Type) Source # 
Instance details

Defined in Data.HList.HList

type HAppendR (HList l1 :: Type) (HList l2 :: Type) = HList (HAppendListR l1 l2)
type HAppendR (Record r1 :: Type) (Record r2 :: Type) Source # 
Instance details

Defined in Data.HList.Record

type HAppendR (Record r1 :: Type) (Record r2 :: Type) = Record (HAppendListR r1 r2)
type HAppendR (TIP l :: Type) (TIP l' :: Type) Source # 
Instance details

Defined in Data.HList.TIP

type HAppendR (TIP l :: Type) (TIP l' :: Type) = TIP (HAppendListR l l')

class HOccurs e l where Source #

Methods

hOccurs :: l -> e Source #

Instances

Instances details
(HOccurrence e (x ': y) l', HOccurs' e l' (x ': y)) => HOccurs e (HList (x ': y)) Source # 
Instance details

Defined in Data.HList.HOccurs

Methods

hOccurs :: HList (x ': y) -> e Source #

HasField e (Record (x ': (y ': l))) e => HOccurs e (TIP (x ': (y ': l))) Source # 
Instance details

Defined in Data.HList.TIP

Methods

hOccurs :: TIP (x ': (y ': l)) -> e Source #

tee ~ Tagged e e => HOccurs e (TIP '[tee]) Source #

One occurrence and nothing is left

This variation provides an extra feature for singleton lists. That is, the result type is unified with the element in the list. Hence the explicit provision of a result type can be omitted.

Instance details

Defined in Data.HList.TIP

Methods

hOccurs :: TIP '[tee] -> e Source #

(HasField o (TIC l) mo, mo ~ Maybe o) => HOccurs mo (TIC l) Source # 
Instance details

Defined in Data.HList.TIC

Methods

hOccurs :: TIC l -> mo Source #

class HOccursNot (e :: k) (l :: [k]) Source #

Instances

Instances details
HOccursNot1 e xs xs => HOccursNot (e :: k) (xs :: [k]) Source # 
Instance details

Defined in Data.HList.HOccurs

class HProject l l' where Source #

Methods

hProject :: l -> l' Source #

Instances

Instances details
(HOccurs e l, HProject l (HList l')) => HProject l (HList (e ': l')) Source # 
Instance details

Defined in Data.HList.HOccurs

Methods

hProject :: l -> HList (e ': l') Source #

HProject (HList l) (HList ('[] :: [Type])) Source # 
Instance details

Defined in Data.HList.HOccurs

Methods

hProject :: HList l -> HList '[] Source #

class HType2HNat (e :: k) (l :: [k]) (n :: HNat) | e l -> n Source #

Map a type (key) to a natural (index) within the collection This is a purely type-level computation

Instances

Instances details
(HEq e1 e b, HType2HNatCase b e1 l n) => HType2HNat (e1 :: Type) (e ': l :: [Type]) n Source #

Map a type to a natural (index within the collection) This is a purely type-level computation

Instance details

Defined in Data.HList.HTypeIndexed

class HTypes2HNats es l (ns :: [HNat]) | es l -> ns Source #

Instances

Instances details
HTypes2HNats ('[] :: [Type]) (l :: [Type]) ('[] :: [HNat]) Source #

And lift to the list of types

Instance details

Defined in Data.HList.HTypeIndexed

(HType2HNat e l n, HTypes2HNats es l ns) => HTypes2HNats (e ': es :: [Type]) (l :: [Type]) (n ': ns) Source # 
Instance details

Defined in Data.HList.HTypeIndexed

class HDeleteMany e l l' | e l -> l' where Source #

Delete all elements with the type-level key e from the collection l. Since the key is type-level, it is represented by a Proxy. (polykinded)

Methods

hDeleteMany :: Proxy e -> l -> l' Source #

Instances

Instances details
HDeleteMany (e :: k) (HList ('[] :: [Type])) (HList ('[] :: [Type])) Source # 
Instance details

Defined in Data.HList.HTypeIndexed

Methods

hDeleteMany :: Proxy e -> HList '[] -> HList '[] Source #

(HEq e1 e b, HDeleteManyCase b e1 e l l1) => HDeleteMany (e1 :: Type) (HList (e ': l)) (HList l1) Source # 
Instance details

Defined in Data.HList.HTypeIndexed

Methods

hDeleteMany :: Proxy e1 -> HList (e ': l) -> HList l1 Source #

class HDeleteAtLabel (r :: [*] -> *) (l :: k) v v' | l v -> v' where Source #

Methods

hDeleteAtLabel :: Label l -> r v -> r v' Source #

Instances

Instances details
H2ProjectByLabels '[Label l] v t1 v' => HDeleteAtLabel Record (l :: k) v v' Source # 
Instance details

Defined in Data.HList.Record

Methods

hDeleteAtLabel :: Label l -> Record v -> Record v' Source #

(HDeleteAtLabel Record e v v', HTypeIndexed v') => HDeleteAtLabel TIP (e :: k) v v' Source # 
Instance details

Defined in Data.HList.TIP

Methods

hDeleteAtLabel :: Label e -> TIP v -> TIP v' Source #

(HDeleteAtHNat n l, HType2HNat e l n, l' ~ HDeleteAtHNatR n l) => HDeleteAtLabel HList (e :: Type) l l' Source #

should this instead delete the first element of that type?

Instance details

Defined in Data.HList.HTypeIndexed

Methods

hDeleteAtLabel :: Label e -> HList l -> HList l' Source #

class SameLengths [x, y, xy] => HUnzip (r :: [*] -> *) x y xy | x y -> xy, xy -> x y where Source #

Methods

hUnzip :: r xy -> (r x, r y) Source #

Instances

Instances details
(SameLengths '[x, y, xy], HZipList x y xy) => HUnzip HList x y xy Source # 
Instance details

Defined in Data.HList.HList

Methods

hUnzip :: HList xy -> (HList x, HList y) Source #

(HZipRecord x y xy, SameLengths '[x, y, xy]) => HUnzip Record x y xy Source # 
Instance details

Defined in Data.HList.Record

Methods

hUnzip :: Record xy -> (Record x, Record y) Source #

(HZipList xL yL xyL, lty ~ (HList xyL -> (HList xL, HList yL)), Coercible lty (TIP xy -> (TIP x, TIP y)), UntagR x ~ xL, TagR xL ~ x, UntagR y ~ yL, TagR yL ~ y, UntagR xy ~ xyL, TagR xyL ~ xy, SameLengths '[x, y, xy], UntagTag x, UntagTag y, UntagTag xy) => HUnzip TIP x y xy Source # 
Instance details

Defined in Data.HList.TIP

Methods

hUnzip :: TIP xy -> (TIP x, TIP y) Source #

(Unvariant '[txy] txy, tx ~ Tagged t x, ty ~ Tagged t y, txy ~ Tagged t (x, y)) => HUnzip Variant '[tx] '[ty] '[txy] Source # 
Instance details

Defined in Data.HList.Variant

Methods

hUnzip :: Variant '[txy] -> (Variant '[tx], Variant '[ty]) Source #

(HUnzip Variant (x2 ': xs) (y2 ': ys) (xy2 ': xys), SameLength xs ys, SameLength ys xys, tx ~ Tagged t x, ty ~ Tagged t y, txy ~ Tagged t (x, y)) => HUnzip Variant (tx ': (x2 ': xs)) (ty ': (y2 ': ys)) (txy ': (xy2 ': xys)) Source # 
Instance details

Defined in Data.HList.Variant

Methods

hUnzip :: Variant (txy ': (xy2 ': xys)) -> (Variant (tx ': (x2 ': xs)), Variant (ty ': (y2 ': ys))) Source #

HUnzip (Proxy :: [Type] -> Type) ('[] :: [Type]) ('[] :: [Type]) ('[] :: [Type]) Source # 
Instance details

Defined in Data.HList.HListPrelude

Methods

hUnzip :: Proxy '[] -> (Proxy '[], Proxy '[]) Source #

(lv ~ Tagged l v, HUnzip (Proxy :: [Type] -> Type) ls vs lvs) => HUnzip (Proxy :: [Type] -> Type) (Label l ': ls) (v ': vs) (lv ': lvs) Source # 
Instance details

Defined in Data.HList.HListPrelude

Methods

hUnzip :: Proxy (lv ': lvs) -> (Proxy (Label l ': ls), Proxy (v ': vs)) Source #

class HUnzip r x y xy => HZip (r :: [*] -> *) x y xy where Source #

zip. Variant supports hUnzip, but not hZip (hZipVariant returns a Maybe)

Methods

hZip :: r x -> r y -> r xy Source #

Instances

Instances details
(SameLengths '[x, y, xy], HZipList x y xy) => HZip HList x y xy Source # 
Instance details

Defined in Data.HList.HList

Methods

hZip :: HList x -> HList y -> HList xy Source #

(HZipRecord x y xy, SameLengths '[x, y, xy]) => HZip Record x y xy Source #
>>> let x :: Record '[Tagged "x" Int]; x = undefined
>>> let y :: Record '[Tagged "x" Char]; y = undefined
>>> :t hZip x y
hZip x y :: Record '[Tagged "x" (Int, Char)]
Instance details

Defined in Data.HList.Record

Methods

hZip :: Record x -> Record y -> Record xy Source #

(HUnzip TIP x y xy, HZipList xL yL xyL, lty ~ (HList xL -> HList yL -> HList xyL), Coercible lty (TIP x -> TIP y -> TIP xy), UntagR x ~ xL, UntagR y ~ yL, UntagR xy ~ xyL, UntagTag x, UntagTag y, UntagTag xy) => HZip TIP x y xy Source # 
Instance details

Defined in Data.HList.TIP

Methods

hZip :: TIP x -> TIP y -> TIP xy Source #

HUnzip (Proxy :: [Type] -> Type) ls vs lvs => HZip (Proxy :: [Type] -> Type) ls vs lvs Source #

Missing from GHC-7.6.3 due to a bug:

let r = hEnd $ hBuild 1 2 3
*Data.HList> hZipList r r
H[(1,1),(2,2),(3,3)]
*Data.HList> hZip r r

<interactive>:30:1:
    Couldn't match type `Label k l' with `Integer'
    When using functional dependencies to combine
      HUnzip
        (Proxy [*]) ((':) * (Label k l) ls) ((':) * v vs) ((':) * lv lvs),
        arising from the dependency `xy -> x y'
        in the instance declaration at Data/HList/HListPrelude.hs:96:10
      HUnzip
        HList
        ((':) * Integer ((':) * Integer ((':) * Integer ('[] *))))
        ((':) * Integer ((':) * Integer ((':) * Integer ('[] *))))
        ((':)
           *
           (Integer, Integer)
           ((':) * (Integer, Integer) ((':) * (Integer, Integer) ('[] *)))),
        arising from a use of `hZip' at <interactive>:30:1-4
    In the expression: hZip r r
    In an equation for `it': it = hZip r r
Instance details

Defined in Data.HList.HListPrelude

Methods

hZip :: Proxy ls -> Proxy vs -> Proxy lvs Source #