31 deriving (Show, Eq, Ord, Read, Typeable)
44 deriving (Show, Eq, Ord, Read, Typeable)
46 instance HList l => HList (e :*: l)
48 (.*.) :: HList l => e -> l -> e :*: l
52 class HExtendable e l where
54 hExtend :: e -> l -> HExtend e l
56 instance HExtendable e HNil where
57 type HExtend e HNil = e :*: HNil
58 hExtend e nil = e .*. nil
60 instance HList l => HExtendable e (e' :*: l) where
61 type HExtend e (e' :*: l) = e :*: e' :*: l
62 hExtend e (e' :*: l) = e .*. e' .*. l
68 class HAppendable l l' where
70 (.++.) :: l -> l' -> l :++: l'
72 instance HList l => HAppendable HNil l where
76 instance ( HAppendable l l'
78 ) => HAppendable (e :*: l) l' where
79 type (e :*: l) :++: l' = e :*: (l :++: l')
80 (e :*: l) .++. l' = e .*. (l .++. l')
83 class Applyable f a where
85 apply :: f -> a -> Apply f a
88 class Applyable2 f a b where
90 apply2 :: f -> a -> b -> Apply2 f a b
95 instance Applyable Id a where
100 data ApplyHAppend = ApplyHAppend
102 instance HAppendable a b => Applyable2 ApplyHAppend a b where
103 type Apply2 ApplyHAppend a b = a :++: b
104 apply2 _ a b = a .++. b
107 class HFoldrable f v l where
109 hFoldr :: f -> v -> l -> HFoldr f v l
111 instance HFoldrable f v HNil where
112 type HFoldr f v HNil = v
115 instance ( HFoldrable f v l
116 , Applyable2 f e (HFoldr f v l)
117 ) => HFoldrable f v (e :*: l) where
118 type HFoldr f v (e :*: l) = Apply2 f e (HFoldr f v l)
119 hFoldr f v (e :*: l) = apply2 f e (hFoldr f v l)
122 class HConcatable ls where
124 hConcat :: ls -> HConcat ls
126 instance HFoldrable ApplyHAppend HNil ls => HConcatable ls where
127 type HConcat ls = HFoldr ApplyHAppend HNil ls
128 hConcat ls = hFoldr ApplyHAppend hNil ls
131 class HMappable f l where
133 hMap :: f -> l -> HMap f l
135 instance HMappable f HNil where
136 type HMap f HNil = HNil
139 instance ( HList (HMap f xs)
142 ) => HMappable f (x :*: xs) where
143 type HMap f (x :*: xs) = Apply f x :*: HMap f xs
144 hMap f (x :*: xs) = apply f x .*. hMap f xs