summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorBartosz Nitka <niteria@gmail.com>2016-04-28 05:40:39 -0700
committerBartosz Nitka <niteria@gmail.com>2016-04-28 05:50:35 -0700
commit82538f65f48f370764691264c3c71b975fd43e16 (patch)
tree83b51c36847ddff57ab25e2fc67e7a757e1dee02 /compiler
parentfa3ba060cdc7f469e7f5c4f7503fadfe99937c90 (diff)
downloadhaskell-82538f65f48f370764691264c3c71b975fd43e16.tar.gz
Kill varSetElems in injImproveEqns
We want to remove varSetElems at the source level because it might be a source of nondeterminism. I don't think it introduces nondeterminism here, but it's easy to do the same thing deterministically for the same price. instFlexiTcS :: [TKVar] -> TcS (TCvSubst, [TcType]) instFlexiTcS currently gives the range of the produced substitution as the second element of the tuple, but it's not used anywhere right now. If it started to be used in the code I'm modifying it would cause nondeterminism problems. Test Plan: ./validate Reviewers: austin, goldfire, bgamari, simonmar, simonpj Reviewed By: simonpj Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2149 GHC Trac Issues: #4012
Diffstat (limited to 'compiler')
-rw-r--r--compiler/typecheck/TcInteract.hs15
1 files changed, 10 insertions, 5 deletions
diff --git a/compiler/typecheck/TcInteract.hs b/compiler/typecheck/TcInteract.hs
index f451af903d..6205844c7d 100644
--- a/compiler/typecheck/TcInteract.hs
+++ b/compiler/typecheck/TcInteract.hs
@@ -1494,7 +1494,7 @@ improve_top_fun_eqs fam_envs fam_tc args rhs_ty
-> (a -> [Type]) -- get LHS of an axiom
-> (a -> Type) -- get RHS of an axiom
-> (a -> Maybe CoAxBranch) -- Just => apartness check required
- -> [( [Type], TCvSubst, TyVarSet, Maybe CoAxBranch )]
+ -> [( [Type], TCvSubst, [TyVar], Maybe CoAxBranch )]
-- Result:
-- ( [arguments of a matching axiom]
-- , RHS-unifying substitution
@@ -1506,15 +1506,20 @@ improve_top_fun_eqs fam_envs fam_tc args rhs_ty
, let ax_args = axiomLHS axiom
, let ax_rhs = axiomRHS axiom
, Just subst <- [tcUnifyTyWithTFs False ax_rhs rhs_ty]
- , let tvs = tyCoVarsOfTypes ax_args
+ , let tvs = tyCoVarsOfTypesList ax_args
notInSubst tv = not (tv `elemVarEnv` getTvSubstEnv subst)
- unsubstTvs = filterVarSet (notInSubst <&&> isTyVar) tvs ]
+ unsubstTvs = filter (notInSubst <&&> isTyVar) tvs ]
injImproveEqns :: [Bool]
- -> ([Type], TCvSubst, TyCoVarSet, Maybe CoAxBranch)
+ -> ([Type], TCvSubst, [TyCoVar], Maybe CoAxBranch)
-> TcS [Eqn]
injImproveEqns inj_args (ax_args, theta, unsubstTvs, cabr) = do
- (theta', _) <- instFlexiTcS (varSetElems unsubstTvs)
+ (theta', _) <- instFlexiTcS unsubstTvs
+ -- The use of deterministically ordered list for `unsubstTvs`
+ -- is not strictly necessary here, we only use the substitution
+ -- part of the result of instFlexiTcS. If we used the second
+ -- part of the tuple, which is the range of the substitution then
+ -- the order could be important.
let subst = theta `unionTCvSubst` theta'
return [ Pair arg (substTyUnchecked subst ax_arg)
| case cabr of