summaryrefslogtreecommitdiff
path: root/compiler/coreSyn
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2014-08-29 10:14:45 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2014-08-29 10:21:37 +0100
commitdfc9d309a5202d65032c80f5b74df17035a61b8c (patch)
tree18fb696fbf94a3c923f4c585ade76f6954b778d7 /compiler/coreSyn
parent2da63c60d0edfc8b3ae9c31f2179fee0dc026edd (diff)
downloadhaskell-dfc9d309a5202d65032c80f5b74df17035a61b8c.tar.gz
Define mapUnionVarSet, and use it
Call sites are much easier to understand than before
Diffstat (limited to 'compiler/coreSyn')
-rw-r--r--compiler/coreSyn/CoreFVs.lhs10
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/coreSyn/CoreFVs.lhs b/compiler/coreSyn/CoreFVs.lhs
index ae162b6a55..44ae8f1d77 100644
--- a/compiler/coreSyn/CoreFVs.lhs
+++ b/compiler/coreSyn/CoreFVs.lhs
@@ -78,7 +78,7 @@ exprFreeIds = exprSomeFreeVars isLocalId
-- | Find all locally-defined free Ids or type variables in several expressions
exprsFreeVars :: [CoreExpr] -> VarSet
-exprsFreeVars = foldr (unionVarSet . exprFreeVars) emptyVarSet
+exprsFreeVars = mapUnionVarSet exprFreeVars
-- | Find all locally defined free Ids in a binding group
bindFreeVars :: CoreBind -> VarSet
@@ -97,7 +97,7 @@ exprSomeFreeVars fv_cand e = expr_fvs e fv_cand emptyVarSet
exprsSomeFreeVars :: InterestingVarFun -- Says which 'Var's are interesting
-> [CoreExpr]
-> VarSet
-exprsSomeFreeVars fv_cand = foldr (unionVarSet . exprSomeFreeVars fv_cand) emptyVarSet
+exprsSomeFreeVars fv_cand = mapUnionVarSet (exprSomeFreeVars fv_cand)
-- | Predicate on possible free variables: returns @True@ iff the variable is interesting
type InterestingVarFun = Var -> Bool
@@ -294,7 +294,7 @@ ruleFreeVars (Rule { ru_fn = _, ru_bndrs = bndrs, ru_rhs = rhs, ru_args = args }
idRuleRhsVars :: (Activation -> Bool) -> Id -> VarSet
-- Just the variables free on the *rhs* of a rule
idRuleRhsVars is_active id
- = foldr (unionVarSet . get_fvs) emptyVarSet (idCoreRules id)
+ = mapUnionVarSet get_fvs (idCoreRules id)
where
get_fvs (Rule { ru_fn = fn, ru_bndrs = bndrs
, ru_rhs = rhs, ru_act = act })
@@ -307,7 +307,7 @@ idRuleRhsVars is_active id
-- | Those variables free in the right hand side of several rules
rulesFreeVars :: [CoreRule] -> VarSet
-rulesFreeVars rules = foldr (unionVarSet . ruleFreeVars) emptyVarSet rules
+rulesFreeVars rules = mapUnionVarSet ruleFreeVars rules
ruleLhsFreeIds :: CoreRule -> VarSet
-- ^ This finds all locally-defined free Ids on the left hand side of a rule
@@ -330,7 +330,7 @@ breaker, which is perfectly inlinable.
\begin{code}
-- |Free variables of a vectorisation declaration
vectsFreeVars :: [CoreVect] -> VarSet
-vectsFreeVars = foldr (unionVarSet . vectFreeVars) emptyVarSet
+vectsFreeVars = mapUnionVarSet vectFreeVars
where
vectFreeVars (Vect _ rhs) = expr_fvs rhs isLocalId emptyVarSet
vectFreeVars (NoVect _) = noFVs