From: Nathaniel Wesley Filardo Date: Thu, 29 Nov 2012 07:10:58 +0000 (-0500) Subject: Add hrllen to HList utilities module X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=b15369baae12c38cfb76c75bb74fbbee8b0da735;p=dyna2 Add hrllen to HList utilities module --- diff --git a/src/Dyna/XXX/HList.hs b/src/Dyna/XXX/HList.hs index 8eecd93..83bc6e2 100644 --- a/src/Dyna/XXX/HList.hs +++ b/src/Dyna/XXX/HList.hs @@ -25,7 +25,7 @@ module Dyna.XXX.HList( HList(..), hlmapa, -- * HLists of a type constructor's images - HRList(..), hrlmapa, hrlmap, hrlproj, hrlTravProj, + HRList(..), hrlmapa, hrllen, hrlmap, hrlproj, hrlTravProj, -- * Interoperation between HList and HRList HLR(..), hlToHrl, @@ -87,6 +87,13 @@ instance Show (HRList r '[]) where show _ = "HRN" instance (Show (r a), Show (HRList r as)) => Show (HRList r (a ': as)) where show (a :++ as) = show a ++ " :+ " ++ show as +hrllen :: HRList r t -> Int +hrllen = go 0 + where + go :: Int -> HRList r t -> Int + go a HRN = a + go a (x :++ xs) = a `seq` go (a+1) xs + -- | Shift the type-function of a HRList hrlmap :: (forall a . r a -> s a) -> HRList r t -> HRList s t hrlmap _ HRN = HRN