module Data.HList.Prelude
( HList
+
, HNil(..)
, hNil
- , (:*:)(..)
- , (.*.)
+
+ , HCons(..)
+ , hCons
, HExtendable(..)
, HAppendable(..)
hNil :: HNil
hNil = HNil
--- :*:
-infixr 2 :*:
-infixr 2 .*.
-
-data e :*: l
- = e :*: l
+-- HCons
+data HCons e l
+ = HCons e l
deriving (Show, Eq, Ord, Read, Typeable)
-instance HList l => HList (e :*: l)
+instance HList l => HList (HCons e l)
-(.*.) :: HList l => e -> l -> e :*: l
-(.*.) = (:*:)
+hCons :: HList l => e -> l -> HCons e l
+hCons = HCons
-- HExtendable
+infixr 2 :*:
+infixr 2 .*.
+
class HExtendable e l where
- type HExtend e l
- hExtend :: e -> l -> HExtend e l
+ type e :*: l
+ (.*.) :: e -> l -> e :*: l
instance HExtendable e HNil where
- type HExtend e HNil = e :*: HNil
- hExtend e nil = e .*. nil
+ type e :*: HNil = HCons e HNil
+ e .*. nil = hCons e nil
-instance HList l => HExtendable e (e' :*: l) where
- type HExtend e (e' :*: l) = e :*: e' :*: l
- hExtend e (e' :*: l) = e .*. e' .*. l
+instance HList l => HExtendable e (HCons e' l) where
+ type e :*: HCons e' l = HCons e (HCons e' l)
+ e .*. HCons e' l = hCons e (hCons e' l)
-- HAppendable
infixr 1 :++:
type HNil :++: l = l
_ .++. l = l
-instance ( HAppendable l l'
- , HList (l :++: l')
- ) => HAppendable (e :*: l) l' where
- type (e :*: l) :++: l' = e :*: (l :++: l')
- (e :*: l) .++. l' = e .*. (l .++. l')
+instance ( HList (l :++: l')
+ , HAppendable l l'
+ ) => HAppendable (HCons e l) l' where
+ type HCons e l :++: l' = HCons e (l :++: l')
+ (HCons e l) .++. l' = hCons e (l .++. l')
-- Applyable
class Applyable f a where
instance ( HFoldrable f v l
, Applyable2 f e (HFoldr f v l)
- ) => HFoldrable f v (e :*: l) where
- type HFoldr f v (e :*: l) = Apply2 f e (HFoldr f v l)
- hFoldr f v (e :*: l) = apply2 f e (hFoldr f v l)
+ ) => HFoldrable f v (HCons e l) where
+ type HFoldr f v (HCons e l) = Apply2 f e (HFoldr f v l)
+ hFoldr f v (HCons e l) = apply2 f e (hFoldr f v l)
-- HConcatable
class HConcatable ls where
instance HMappable f HNil where
type HMap f HNil = HNil
- hMap _ _ = HNil
+ hMap _ _ = hNil
-instance ( HList (HMap f xs)
- , Applyable f x
+instance ( Applyable f x
, HMappable f xs
- ) => HMappable f (x :*: xs) where
- type HMap f (x :*: xs) = Apply f x :*: HMap f xs
- hMap f (x :*: xs) = apply f x .*. hMap f xs
+ , HList (HMap f xs)
+ ) => HMappable f (HCons x xs) where
+ type HMap f (HCons x xs) = HCons (Apply f x) (HMap f xs)
+ hMap f (HCons x xs) = hCons (apply f x) (hMap f xs)