summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Dammers <tdammers@gmail.com>2018-09-12 22:47:56 +0200
committerTobias Dammers <tdammers@gmail.com>2018-09-12 22:47:56 +0200
commit17732b472bebbe0341f6992dce6bd259e176725c (patch)
tree023d307db6b1ee6c7339330090e2f5b8d6d9e02b
parent2728d63f0a42251d24d5fc4f044633f981891131 (diff)
downloadhaskell-17732b472bebbe0341f6992dce6bd259e176725c.tar.gz
Avoid going through FV when closing over kinds (#14880)
-rw-r--r--compiler/basicTypes/VarSet.hs8
-rw-r--r--compiler/types/TyCoRep.hs5
2 files changed, 9 insertions, 4 deletions
diff --git a/compiler/basicTypes/VarSet.hs b/compiler/basicTypes/VarSet.hs
index ac3c545b2a..1c82b380b7 100644
--- a/compiler/basicTypes/VarSet.hs
+++ b/compiler/basicTypes/VarSet.hs
@@ -13,7 +13,7 @@ module VarSet (
emptyVarSet, unitVarSet, mkVarSet,
extendVarSet, extendVarSetList,
elemVarSet, subVarSet,
- unionVarSet, unionVarSets, mapUnionVarSet,
+ unionVarSet, unionVarSets, mapUnionVarSet, mapUnionVarSetSet,
intersectVarSet, intersectsVarSet, disjointVarSet,
isEmptyVarSet, delVarSet, delVarSetList, delVarSetByKey,
minusVarSet, filterVarSet, mapVarSet,
@@ -85,6 +85,9 @@ unionVarSets :: [VarSet] -> VarSet
mapUnionVarSet :: (a -> VarSet) -> [a] -> VarSet
-- ^ map the function over the list, and union the results
+mapUnionVarSetSet :: (Var -> VarSet) -> VarSet -> VarSet
+-- ^ map the function over the set, and union the results
+
unitVarSet :: Var -> VarSet
extendVarSet :: VarSet -> Var -> VarSet
extendVarSetList:: VarSet -> [Var] -> VarSet
@@ -137,6 +140,9 @@ partitionVarSet = partitionUniqSet
mapUnionVarSet get_set xs = foldr (unionVarSet . get_set) emptyVarSet xs
+mapUnionVarSetSet get_set =
+ nonDetFoldUniqSet (\var acc -> get_set var `unionVarSet` acc) emptyVarSet
+
-- See comments with type signatures
intersectsVarSet s1 s2 = not (s1 `disjointVarSet` s2)
disjointVarSet s1 s2 = disjointUFM (getUniqSet s1) (getUniqSet s2)
diff --git a/compiler/types/TyCoRep.hs b/compiler/types/TyCoRep.hs
index d2cb070313..282328073a 100644
--- a/compiler/types/TyCoRep.hs
+++ b/compiler/types/TyCoRep.hs
@@ -1898,9 +1898,8 @@ coVarsOfCos = mapUnionVarSet coVarsOfCo
-- | Add the kind variables free in the kinds of the tyvars in the given set.
-- Returns a non-deterministic set.
closeOverKinds :: TyVarSet -> TyVarSet
-closeOverKinds = fvVarSet . closeOverKindsFV . nonDetEltsUniqSet
- -- It's OK to use nonDetEltsUniqSet here because we immediately forget
- -- about the ordering by returning a set.
+closeOverKinds tvs =
+ mapUnionVarSetSet (tyCoVarsOfType . tyVarKind) tvs `unionVarSet` tvs
-- | Given a list of tyvars returns a deterministic FV computation that
-- returns the given tyvars with the kind variables free in the kinds of the