The HList library
(C) 2004, Oleg Kiselyov, Ralf Laemmel, Keean Schupke
Result-type-driven operations on typeful heterogeneous lists.
- class HOccursMany e l where
- hOccursMany :: l -> [e]
- class HOccursMany1 e l where
- hOccursMany1 :: l -> (e, [e])
- class HOccursFst e l where
- hOccursFst :: l -> e
- class HOccurs e l where
- hOccurs :: l -> e
- data TypeNotFound e
- class HOccurs' e l where
- hOccurs' :: l -> e
- class HOccursBool b e l where
- hOccursBool :: b -> l -> e
- class HOccursOpt e l where
- hOccursOpt :: l -> Maybe e
- data TypeFound e
- class HOccursNot e l
- class HProject l l' where
- hProject :: l -> l'
Documentation
class HOccursMany e l whereSource
hOccursMany :: l -> [e]Source
HOccursMany e HNil | |
HOccursMany e l => HOccursMany e (TIP l) | |
(HOccursMany e l, HList l) => HOccursMany e (HCons e' l) | |
(HOccursMany e l, HList l) => HOccursMany e (HCons e l) |
class HOccursMany1 e l whereSource
hOccursMany1 :: l -> (e, [e])Source
HOccursMany1 e l => HOccursMany1 e (TIP l) | |
(HOccursMany1 e l, HList l) => HOccursMany1 e (HCons e' l) | |
(HOccursMany e l, HList l) => HOccursMany1 e (HCons e l) |
class HOccursFst e l whereSource
hOccursFst :: l -> eSource
HOccursFst e l => HOccursFst e (TIP l) | |
(HOccursFst e l, HList l) => HOccursFst e (HCons e' l) | |
HList l => HOccursFst e (HCons e l) |
data TypeNotFound e Source
class HOccurs' e l whereSource
(TypeEq e e' b, HOccursBool b e (HCons e' l)) => HOccurs' e (HCons e' l) |
class HOccursBool b e l whereSource
hOccursBool :: b -> l -> eSource
(HOccurs' e l, HList l) => HOccursBool HFalse e (HCons e' l) | |
(HList l, HOccursNot e l) => HOccursBool HTrue e (HCons e l) |
class HOccursOpt e l whereSource
hOccursOpt :: l -> Maybe eSource
HOccursOpt e HNil | |
HOccursOpt e l => HOccursOpt e (TIP l) | |
HOccursOpt e l => HOccursOpt e (HCons e' l) | |
HOccursOpt e (HCons e l) |
class HOccursNot e l Source
HOccursNot e HNil | |
HOccursNot e l => HOccursNot e (TIP l) | |
HOccursNot e l => HOccursNot e (HCons e' l) | |
Fail (TypeFound e) => HOccursNot e (HCons e l) |
Illustration of typical test scenarios
Retrieve the Breed of an animal.
ghci-or-hugs> hOccurs myAnimal :: Breed Cow
Normal hOccurs requires specification of the result type even if the result type is determined by the fact that we are faced with a singleton list.
ghci-or-hugs> hOccurs (HCons 1 HNil) <interactive>:1: No instance for (HOccurs e1 (HCons e HNil))
However, hOccurs can be elaborated as improved as follows:
ghci-or-hugs> hLookup (HCons 1 HNil) 1