[commit: ghc] wip/ghc-8.0-det: Kill varSetElems in injImproveEqns (0e860a2)

git at git.haskell.org git at git.haskell.org
Mon Jul 18 17:58:03 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/ghc-8.0-det
Link       : http://ghc.haskell.org/trac/ghc/changeset/0e860a205cbb33b48c03c4bab731aa5a39dd4233/ghc

>---------------------------------------------------------------

commit 0e860a205cbb33b48c03c4bab731aa5a39dd4233
Author: Bartosz Nitka <niteria at gmail.com>
Date:   Thu Apr 28 05:40:39 2016 -0700

    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


>---------------------------------------------------------------

0e860a205cbb33b48c03c4bab731aa5a39dd4233
 compiler/typecheck/TcInteract.hs | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/compiler/typecheck/TcInteract.hs b/compiler/typecheck/TcInteract.hs
index 39ad787..ca5d912 100644
--- a/compiler/typecheck/TcInteract.hs
+++ b/compiler/typecheck/TcInteract.hs
@@ -1491,7 +1491,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
@@ -1503,15 +1503,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



More information about the ghc-commits mailing list