[commit: ghc] wip/ghc-8.0-det: Kill unnecessary varSetElemsWellScoped in deriveTyData (b874bc9)

git at git.haskell.org git at git.haskell.org
Mon Jul 25 14:57:58 UTC 2016


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

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

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

commit b874bc9b11eb1961a04200dace1c530b6fe525ce
Author: Bartosz Nitka <niteria at gmail.com>
Date:   Wed Apr 20 08:54:10 2016 -0700

    Kill unnecessary varSetElemsWellScoped in deriveTyData
    
    varSetElemsWellScoped introduces unnecessary non-determinism and it's possible
    to do the same thing deterministically for the same price.
    
    Test Plan: ./validate
    
    Reviewers: austin, simonmar, bgamari, simonpj
    
    Reviewed By: simonpj
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D2124
    
    GHC Trac Issues: #4012
    
    (cherry picked from commit 687c77808b82e8cf8c77fba2c0ed2fe003c907cf)


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

b874bc9b11eb1961a04200dace1c530b6fe525ce
 compiler/typecheck/TcDeriv.hs | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/compiler/typecheck/TcDeriv.hs b/compiler/typecheck/TcDeriv.hs
index 03f593c..39c9bfc 100644
--- a/compiler/typecheck/TcDeriv.hs
+++ b/compiler/typecheck/TcDeriv.hs
@@ -63,6 +63,7 @@ import Outputable
 import FastString
 import Bag
 import Pair
+import FV (runFVList, unionFV, someVars)
 import qualified GHC.LanguageExtensions as LangExt
 
 import Control.Monad
@@ -651,9 +652,11 @@ deriveTyData tvs tc tc_args deriv_pred
               mb_match        = tcUnifyTy inst_ty_kind cls_arg_kind
               Just kind_subst = mb_match
 
-              all_tkvs        = varSetElemsWellScoped $
-                                mkVarSet deriv_tvs `unionVarSet`
-                                tyCoVarsOfTypes tc_args_to_keep
+              all_tkvs        = toposortTyVars $
+                                runFVList $ unionFV
+                                  (tyCoVarsOfTypesAcc tc_args_to_keep)
+                                  (someVars deriv_tvs)
+
               unmapped_tkvs   = filter (`notElemTCvSubst` kind_subst) all_tkvs
               (subst, tkvs)   = mapAccumL substTyVarBndr
                                           kind_subst unmapped_tkvs



More information about the ghc-commits mailing list