From: Matthijs Kooijman Date: Mon, 9 Feb 2009 16:18:40 +0000 (+0100) Subject: Make HsValueMap an instance of Functor. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=9d4873628a889f02b7a4124505dbe18307ecb6e8;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Make HsValueMap an instance of Functor. --- diff --git a/Flatten.hs b/Flatten.hs index 7ce63a5..42ce020 100644 --- a/Flatten.hs +++ b/Flatten.hs @@ -17,7 +17,9 @@ data HsValueMap mapto = | Single mapto deriving (Show, Eq) - +instance Functor HsValueMap where + fmap f (Single s) = Single (f s) + fmap f (Tuple maps) = Tuple (fmap (fmap f) maps) -- | Creates a HsValueMap with the same structure as the given type, using the -- given function for mapping the single types. @@ -57,8 +59,7 @@ type SignalUseMap = HsValueMap SignalUse type SignalDefMap = HsValueMap SignalDef useMapToDefMap :: SignalUseMap -> SignalDefMap -useMapToDefMap (Single (SignalUse u)) = Single (SignalDef u) -useMapToDefMap (Tuple uses) = Tuple (map useMapToDefMap uses) +useMapToDefMap = fmap (\(SignalUse u) -> SignalDef u) type SignalId = Int data SignalUse = SignalUse {