summaryrefslogtreecommitdiff
path: root/compiler/specialise/Rules.hs
diff options
context:
space:
mode:
authorBartosz Nitka <niteria@gmail.com>2016-04-15 04:46:21 -0700
committerBartosz Nitka <niteria@gmail.com>2016-04-15 04:47:04 -0700
commit928d74733975fe4677e2b558d031779f58a0883c (patch)
tree2ccbad3cabc4594c45792425ef2f01c4a535335e /compiler/specialise/Rules.hs
parentf4fd98c717a7f68d76a3054021b3be65d1ebad82 (diff)
downloadhaskell-928d74733975fe4677e2b558d031779f58a0883c.tar.gz
Kill some unnecessary varSetElems
When you do `varSetElems (tyCoVarsOfType x)` it's equivalent to `tyCoVarsOfTypeList x`. Why? If you look at the implementation: ``` tyCoVarsOfTypeList ty = runFVList $ tyCoVarsOfTypeAcc ty tyCoVarsOfType ty = runFVSet $ tyCoVarsOfTypeAcc ty ``` they use the same helper function. The helper function returns a deterministically ordered list and a set. The only difference between the two is which part of the result they take. It is redundant to take the set and then immediately convert it to a list. This helps with determinism and we eventually want to replace the uses of `varSetElems` with functions that don't leak the values of uniques. This change gets rid of some instances that are easy to kill. I chose not to annotate every place where I got rid of `varSetElems` with a comment about non-determinism, because once we get rid of `varSetElems` it will not be possible to do the wrong thing. Test Plan: ./validate Reviewers: goldfire, austin, simonmar, bgamari, simonpj Reviewed By: simonpj Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2115 GHC Trac Issues: #4012
Diffstat (limited to 'compiler/specialise/Rules.hs')
-rw-r--r--compiler/specialise/Rules.hs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/specialise/Rules.hs b/compiler/specialise/Rules.hs
index 24b52d3db7..3adad1c83e 100644
--- a/compiler/specialise/Rules.hs
+++ b/compiler/specialise/Rules.hs
@@ -33,7 +33,7 @@ import Module ( Module, ModuleSet, elemModuleSet )
import CoreSubst
import OccurAnal ( occurAnalyseExpr )
import CoreFVs ( exprFreeVars, exprsFreeVars, bindFreeVars
- , rulesFreeVarsDSet, exprsOrphNames )
+ , rulesFreeVarsDSet, exprsOrphNames, exprFreeVarsList )
import CoreUtils ( exprType, eqExpr, mkTick, mkTicks,
stripTicksTopT, stripTicksTopE )
import PprCore ( pprRules )
@@ -898,7 +898,7 @@ match_tmpl_var :: RuleMatchEnv
match_tmpl_var renv@(RV { rv_lcl = rn_env, rv_fltR = flt_env })
subst@(RS { rs_id_subst = id_subst, rs_bndrs = let_bndrs })
v1' e2
- | any (inRnEnvR rn_env) (varSetElems (exprFreeVars e2))
+ | any (inRnEnvR rn_env) (exprFreeVarsList e2)
= Nothing -- Occurs check failure
-- e.g. match forall a. (\x-> a x) against (\y. y y)