diff --git a/common/Pass.hs b/common/Pass.hs index 188ee5b..bc758dd 100644 --- a/common/Pass.hs +++ b/common/Pass.hs @@ -42,7 +42,7 @@ instance Die PassM where type Pass = A.Process -> PassM A.Process -- | Compose a list of passes into a single pass. -runPasses :: [(String, Pass)] -> A.Process -> PassM A.Process +runPasses :: [(String, Pass)] -> Pass runPasses [] ast = return ast runPasses ((s, p):ps) ast = do debug $ "{{{ " ++ s @@ -83,7 +83,7 @@ veryDebug :: (CSM m, MonadIO m) => String -> m () veryDebug = verboseMessage 3 -- | Dump the AST and parse state. -debugAST :: (CSM m, MonadIO m) => A.Process -> m () +debugAST :: (CSM m, MonadIO m, Data t) => t -> m () debugAST p = do veryDebug $ "{{{ AST" veryDebug $ pshow p diff --git a/transformations/SimplifyComms.hs b/transformations/SimplifyComms.hs index 29a2c43..17ef40b 100644 --- a/transformations/SimplifyComms.hs +++ b/transformations/SimplifyComms.hs @@ -29,7 +29,7 @@ import Metadata import Types import Pass -simplifyComms :: A.Process -> PassM A.Process +simplifyComms :: Pass simplifyComms = runPasses passes where passes = diff --git a/transformations/SimplifyExprs.hs b/transformations/SimplifyExprs.hs index 922c709..0177f34 100644 --- a/transformations/SimplifyExprs.hs +++ b/transformations/SimplifyExprs.hs @@ -30,7 +30,7 @@ import Metadata import Pass import Types -simplifyExprs :: A.Process -> PassM A.Process +simplifyExprs :: Pass simplifyExprs = runPasses passes where passes = diff --git a/transformations/SimplifyProcs.hs b/transformations/SimplifyProcs.hs index b5d22b5..4b0a3c2 100644 --- a/transformations/SimplifyProcs.hs +++ b/transformations/SimplifyProcs.hs @@ -28,7 +28,7 @@ import Metadata import Types import Pass -simplifyProcs :: A.Process -> PassM A.Process +simplifyProcs :: Pass simplifyProcs = runPasses passes where passes = diff --git a/transformations/SimplifyTypes.hs b/transformations/SimplifyTypes.hs index a0f3184..548f2fe 100644 --- a/transformations/SimplifyTypes.hs +++ b/transformations/SimplifyTypes.hs @@ -26,7 +26,7 @@ import qualified AST as A import Pass import Types -simplifyTypes :: A.Process -> PassM A.Process +simplifyTypes :: Pass simplifyTypes = runPasses passes where passes = @@ -46,10 +46,6 @@ resolveNamedTypes = doGeneric `extM` doType doType t = doGeneric t -- | Resolve named types in CompState. -rntState :: A.Process -> PassM A.Process -rntState p - = do st <- get - st' <- resolveNamedTypes st - put st' - return p +rntState :: Data t => t -> PassM t +rntState p = (get >>= resolveNamedTypes >>= put) >> return p diff --git a/transformations/Unnest.hs b/transformations/Unnest.hs index 02321fa..f0ba51f 100644 --- a/transformations/Unnest.hs +++ b/transformations/Unnest.hs @@ -32,7 +32,7 @@ import Metadata import Pass import Types -unnest :: A.Process -> PassM A.Process +unnest :: Pass unnest = runPasses passes where passes =