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
- data TypeFound e
- class HOccursNot e l
- class HProject l l' where
- hProject :: l -> 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