[commit: ghc] master: Kill varSetElems in injImproveEqns (82538f6)

git at git.haskell.org git at git.haskell.org
Thu Apr 28 12:48:08 UTC 2016


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/82538f65f48f370764691264c3c71b975fd43e16/ghc

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

commit 82538f65f48f370764691264c3c71b975fd43e16
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


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

82538f65f48f370764691264c3c71b975fd43e16
 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 f451af9..6205844 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



More information about the ghc-commits mailing list