X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=hs-rrdtool.git;a=blobdiff_plain;f=Data%2FHList%2FPrelude.hs;h=b3a88fdb0c2371d20828f9ecf802f993a431d264;hp=b3e6b95bd4da779bced5e300c757b9a534b72866;hb=135df1a5d8a159db412614bcfc25634bee201f94;hpb=b7e8a37aa24e9bda11995613c45187e6e19e0c01 diff --git a/Data/HList/Prelude.hs b/Data/HList/Prelude.hs index b3e6b95..b3a88fd 100644 --- a/Data/HList/Prelude.hs +++ b/Data/HList/Prelude.hs @@ -1,9 +1,11 @@ module Data.HList.Prelude ( HList + , HNil(..) , hNil - , (:*:)(..) - , (.*.) + + , HCons(..) + , hCons , HExtendable(..) , HAppendable(..) @@ -36,31 +38,31 @@ instance HList HNil 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 :++: @@ -74,11 +76,11 @@ instance HList l => HAppendable HNil l where 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 @@ -115,9 +117,9 @@ instance HFoldrable f v HNil 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 @@ -135,11 +137,11 @@ class HMappable f l 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)