Move everywhereASTM into Pass.
This commit is contained in:
parent
79eefd5e98
commit
b8caf7c3b6
|
@ -47,15 +47,6 @@ recordInfNameTypes = everywhereM (mkM recordInfNameTypes')
|
|||
return input
|
||||
recordInfNameTypes' r = return r
|
||||
|
||||
everywhereASTM :: (Data s, Data t) => (s -> PassM s) -> t -> PassM t
|
||||
everywhereASTM f = doGeneric `extM` (doSpecific f)
|
||||
where
|
||||
doGeneric :: Data t => t -> PassM t
|
||||
doGeneric = makeGeneric (everywhereASTM f)
|
||||
|
||||
doSpecific :: Data t => (t -> PassM t) -> t -> PassM t
|
||||
doSpecific f x = (doGeneric x >>= f)
|
||||
|
||||
-- | Folds all constants.
|
||||
constantFoldPass :: Data t => t -> PassM t
|
||||
constantFoldPass = everywhereASTM doExpression
|
||||
|
|
11
pass/Pass.hs
11
pass/Pass.hs
|
@ -194,6 +194,17 @@ makeGeneric top
|
|||
`extM` (return :: String -> m String)
|
||||
`extM` (return :: Meta -> m Meta)
|
||||
|
||||
-- | Apply a monadic operation everywhere that it matches in the AST, going
|
||||
-- depth-first.
|
||||
everywhereASTM :: (Data s, Data t) => (s -> PassM s) -> t -> PassM t
|
||||
everywhereASTM f = doGeneric `extM` (doSpecific f)
|
||||
where
|
||||
doGeneric :: Data t => t -> PassM t
|
||||
doGeneric = makeGeneric (everywhereASTM f)
|
||||
|
||||
doSpecific :: Data t => (t -> PassM t) -> t -> PassM t
|
||||
doSpecific f x = (doGeneric x >>= f)
|
||||
|
||||
excludeConstr :: (Data a, CSMR m) => [Constr] -> a -> m a
|
||||
excludeConstr cons x
|
||||
= if null items then return x else dieInternal (Nothing, "Excluded item still remains in source tree: " ++ (show $ head items) ++ " tree is: " ++ pshow x)
|
||||
|
|
Loading…
Reference in New Issue
Block a user