This function performs a number of substitutions on a CoreExpr, by using
the CoreSubst module.
import qualified Type
import qualified IdInfo
import qualified CoreUtils
+import qualified CoreSubst
import Outputable ( showSDoc, ppr, nest )
-- Local imports
let (us', us'') = UniqSupply.splitUniqSupply us
putA tsUniqSupply us'
return $ UniqSupply.uniqFromSupply us''
+
+-- Replace each of the binders given with the coresponding expressions in the
+-- given expression.
+substitute :: [(CoreBndr, CoreExpr)] -> CoreExpr -> CoreExpr
+substitute replace expr = CoreSubst.substExpr subs expr
+ where subs = foldl (\s (b, e) -> CoreSubst.extendIdSubst s b e) CoreSubst.emptySubst replace