From b15369baae12c38cfb76c75bb74fbbee8b0da735 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Thu, 29 Nov 2012 02:10:58 -0500 Subject: [PATCH] Add hrllen to HList utilities module --- src/Dyna/XXX/HList.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 -- 2.50.1