HList-0.2.3: Heterogeneous lists

Data.HList.HOccurs

Contents

Description

The HList library

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

Result-type-driven operations on typeful heterogeneous lists.

Synopsis

Documentation

class HOccursMany e l whereSource

Methods

hOccursMany :: l -> [e]Source

Instances

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

Methods

hOccursMany1 :: l -> (e, [e])Source

Instances

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

Methods

hOccursFst :: l -> eSource

Instances

HOccursFst e l => HOccursFst e (TIP l) 
(HOccursFst e l, HList l) => HOccursFst e (HCons e' l) 
HList l => HOccursFst e (HCons e l) 

class HOccurs e l whereSource

Methods

hOccurs :: l -> eSource

Instances

Fail (TypeNotFound e) => HOccurs e HNil 
HOccurs e (HCons x (HCons y l)) => HOccurs e (TIP (HCons x (HCons y l))) 
TypeCast e' e => HOccurs e (TIP (HCons e' HNil)) 
(HOccurs e l, HList l) => HOccurs e (HCons e' l) 
(HList l, HOccursNot e l) => HOccurs e (HCons e l) 

class HOccurs' e l whereSource

Methods

hOccurs' :: l -> eSource

Instances

(TypeEq e e' b, HOccursBool b e (HCons e' l)) => HOccurs' e (HCons e' l) 

class HOccursBool b e l whereSource

Methods

hOccursBool :: b -> l -> eSource

Instances

(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

Methods

hOccursOpt :: l -> Maybe eSource

Instances

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

Instances

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) 

class HProject l l' whereSource

Methods

hProject :: l -> l'Source

Instances

HProject l HNil 
(HList l', HOccurs e l, HProject l l') => HProject l (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