HList-0.4.1.0: Heterogeneous lists

Safe HaskellNone
LanguageHaskell2010

Data.HList.TypeEqO

Description

The HList library

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

Generic type equality predicate: The implementation based on overlapping instances The only place where overlapping instances are really used besides Label5

Synopsis

Documentation

class TupleType t b | t -> b Source

Instances

TupleType () True 
(~) Bool False b => TupleType x b 
TupleType (x, y) True 
TupleType (x, y, z) True 

class IsKeyFN t flag | t -> flag Source

All our keywords must be registered

Instances

(~) Bool False flag => IsKeyFN t flag

overlapping/fallback case

IsKeyFN (Label Symbol s -> a -> b) True

labels that impose no restriction on the type of the (single) argument which follows

>>> let testF (_ :: Label "a") (a :: Int) () = a+1
>>> kw (hBuild testF) (Label :: Label "a") 5 ()
6
(~) * r (c -> b) => IsKeyFN (K k s c -> r) True

The purpose of this instance is to be able to use the same Symbol (type-level string) at different types. If they are supposed to be the same, then use Label instead of K

>>> let kA = K :: forall t. K "a" t
>>> let testF (K :: K "a" Int) a1 (K :: K "a" Integer) a2 () = a1-fromIntegral a2

therefore the following options works:

>>> kw (hBuild testF) kA (5 :: Int) kA (3 :: Integer) ()
2
>>> kw (hBuild testF) (K :: K "a" Integer) 3 (K :: K "a" Int) 5 ()
2

But you cannot leave off all Int or Integer annotations.