diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-11-10 21:41:33 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-12-03 21:04:50 -0500 |
commit | 78b67ad0e891fc3b66df72643fb173dc985e8306 (patch) | |
tree | 2520251bf1af6fea29c6f461dab5985a3f12fe95 /compiler/types | |
parent | 25019d18109cd620a2cf6ab0e7d417d14935e8a5 (diff) | |
download | haskell-78b67ad0e891fc3b66df72643fb173dc985e8306.tar.gz |
Simplify uniqAway
This does two things:
* Eliminate all uses of Unique.deriveUnique, which was quite easy to
mis-use and extremely subtle.
* Rename the previous "derived unique" notion to "local unique". This
is possible because the only places where `uniqAway` can be safely
used are those where local uniqueness (with respect to some
InScopeSet) is sufficient.
* Rework the implementation of VarEnv.uniqAway, as discussed in #17462.
This should make the operation significantly more efficient than its
previous iterative implementation..
Metric Decrease:
T9872c
T12227
T9233
T14683
T5030
T12545
hie002
Metric Increase:
T9961
Diffstat (limited to 'compiler/types')
-rw-r--r-- | compiler/types/FamInstEnv.hs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/types/FamInstEnv.hs b/compiler/types/FamInstEnv.hs index b491948cd9..168cc0fc40 100644 --- a/compiler/types/FamInstEnv.hs +++ b/compiler/types/FamInstEnv.hs @@ -50,7 +50,6 @@ import CoAxiom import VarSet import VarEnv import Name -import PrelNames ( eqPrimTyConKey ) import UniqDFM import Outputable import Maybes @@ -1772,9 +1771,8 @@ coreFlattenCo :: TvSubstEnv -> FlattenEnv coreFlattenCo subst env co = (env2, mkCoVarCo covar) where - fresh_name = mkFlattenFreshCoName (env1, kind') = coreFlattenTy subst env (coercionType co) - covar = uniqAway (fe_in_scope env1) (mkCoVar fresh_name kind') + covar = mkFlattenFreshCoVar (fe_in_scope env1) kind' -- Add the covar to the FlattenEnv's in-scope set. -- See Note [Flattening], wrinkle 2A. env2 = updateInScopeSet env1 (flip extendInScopeSet covar) @@ -1827,6 +1825,8 @@ mkFlattenFreshTyName :: Uniquable a => a -> Name mkFlattenFreshTyName unq = mkSysTvName (getUnique unq) (fsLit "flt") -mkFlattenFreshCoName :: Name -mkFlattenFreshCoName - = mkSystemVarName (deriveUnique eqPrimTyConKey 71) (fsLit "flc") +mkFlattenFreshCoVar :: InScopeSet -> Kind -> CoVar +mkFlattenFreshCoVar in_scope kind + = let uniq = unsafeGetFreshLocalUnique in_scope + name = mkSystemVarName uniq (fsLit "flc") + in mkCoVar name kind |