From: Matthijs Kooijman Date: Mon, 16 Feb 2009 15:58:38 +0000 (+0100) Subject: Reduce genSignals to a single line using Traversable. X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fmaster-project%2Fc%CE%BBash.git;a=commitdiff_plain;h=b70c4a4b8578f13762f87a33133e2e205e1de9b6 Reduce genSignals to a single line using Traversable. --- diff --git a/Flatten.hs b/Flatten.hs index f7ab86c..c8b95b4 100644 --- a/Flatten.hs +++ b/Flatten.hs @@ -7,6 +7,7 @@ import qualified Name import qualified Maybe import qualified DataCon import qualified CoreUtils +import qualified Data.Traversable as Traversable import Control.Applicative import Outputable ( showSDoc, ppr ) import qualified Control.Monad.State as State @@ -27,24 +28,10 @@ genSignals :: Type.Type -> FlattenState (SignalMap UnnamedSignal) -genSignals ty = do - typeMapToUseMap SigInternal tymap - where - -- First generate a map with the right structure containing the types - tymap = mkHsValueMap ty - -typeMapToUseMap :: - SigUse - -> HsValueMap Type.Type - -> FlattenState (SignalMap UnnamedSignal) - -typeMapToUseMap use (Single ty) = do - id <- genSignalId use ty - return $ Single id - -typeMapToUseMap use (Tuple tymaps) = do - usemaps <- State.mapM (typeMapToUseMap use) tymaps - return $ Tuple usemaps +genSignals ty = + -- First generate a map with the right structure containing the types, and + -- generate signals for each of them. + Traversable.mapM (\ty -> genSignalId SigInternal ty) (mkHsValueMap ty) -- | Flatten a haskell function flattenFunction ::