From 56c7e95a268187a0dd4aea1fa9e669755247c79b Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 18 Jun 2009 14:47:56 +0200 Subject: [PATCH] Add a substitute helper function. This function performs a number of substitutions on a CoreExpr, by using the CoreSubst module. --- NormalizeTools.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NormalizeTools.hs b/NormalizeTools.hs index 91e5b45..193af61 100644 --- a/NormalizeTools.hs +++ b/NormalizeTools.hs @@ -23,6 +23,7 @@ import qualified SrcLoc import qualified Type import qualified IdInfo import qualified CoreUtils +import qualified CoreSubst import Outputable ( showSDoc, ppr, nest ) -- Local imports @@ -140,3 +141,9 @@ mkUnique = Trans.lift $ do 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 -- 2.30.2