Commit 82538f65 authored by niteria's avatar niteria
Browse files

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:

GHC Trac Issues: #4012
parent fa3ba060
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment