X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=hs-rrdtool.git;a=blobdiff_plain;f=Data%2FHList%2FPrelude.hs;h=d9ee19a89211b532ff20f01e6a0409e7e8eef94a;hp=c63be3ab5d486cae5c20f4fa35db3231e50c1249;hb=3ac7657c591da8c12909fd3a5eb3b07d835c8e93;hpb=57b97113a93d366f14278a12b8170a1c06e258a1 diff --git a/Data/HList/Prelude.hs b/Data/HList/Prelude.hs index c63be3a..d9ee19a 100644 --- a/Data/HList/Prelude.hs +++ b/Data/HList/Prelude.hs @@ -27,12 +27,14 @@ module Data.HList.Prelude , HFoldrable(..) , HConcatable(..) , HMappable(..) + , HAllable(..) , HLength ) where import Data.Typeable +import Types.Data.Bool import Types.Data.Num hiding ((:*:)) @@ -157,6 +159,26 @@ instance ( Applyable f x 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) +-- HAllable +class HAllable f l where + type HAll f l + hAll :: f -> l -> HAll f l + +instance HAllable f HNil where + type HAll f HNil = True + hAll _ _ = undefined :: True + +instance ( IfT (Apply f x) (HAll f xs) False + , Applyable f x + , HAllable f xs + ) => HAllable f (HCons x xs) where + type HAll f (HCons x xs) = If (Apply f x) + (HAll f xs) + False + hAll f (HCons x xs) = ifT (apply f x) + (hAll f xs) + (undefined :: False) + -- HLength type family HLength l type instance HLength HNil = D0