summaryrefslogtreecommitdiff
path: root/compiler/utils/UniqDFM.hs
diff options
context:
space:
mode:
authorBartosz Nitka <niteria@gmail.com>2016-05-24 04:44:37 -0700
committerBartosz Nitka <niteria@gmail.com>2016-05-24 05:43:12 -0700
commit9d06ef1ae451a145607301dc7556931b537a7d83 (patch)
tree9385f43159fb1c7ddda5bb2e20107eaa7b8f3c3f /compiler/utils/UniqDFM.hs
parent4c6e69d58a300d6ef440d326a3fd29b58b284fa1 (diff)
downloadhaskell-9d06ef1ae451a145607301dc7556931b537a7d83.tar.gz
Make Arrow desugaring deterministic
This kills two instances of varSetElems that turned out to be nondeterministic. I've tried to untangle this before, but it's a bit hard with the fixDs in the middle. Fortunately I now have a test case that proves that we need determinism here. Test Plan: ./validate, new testcase Reviewers: simonpj, simonmar, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2258 GHC Trac Issues: #4012
Diffstat (limited to 'compiler/utils/UniqDFM.hs')
-rw-r--r--compiler/utils/UniqDFM.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/utils/UniqDFM.hs b/compiler/utils/UniqDFM.hs
index 4bd97ef2eb..91fb0ecbec 100644
--- a/compiler/utils/UniqDFM.hs
+++ b/compiler/utils/UniqDFM.hs
@@ -42,7 +42,7 @@ module UniqDFM (
filterUDFM,
isNullUDFM,
sizeUDFM,
- intersectUDFM,
+ intersectUDFM, udfmIntersectUFM,
intersectsUDFM,
disjointUDFM, disjointUdfmUfm,
minusUDFM,
@@ -275,6 +275,11 @@ intersectUDFM (UDFM x i) (UDFM y _j) = UDFM (M.intersection x y) i
-- M.intersection is left biased, that means the result will only have
-- a subset of elements from the left set, so `i` is a good upper bound.
+udfmIntersectUFM :: UniqDFM elt -> UniqFM elt -> UniqDFM elt
+udfmIntersectUFM (UDFM x i) y = UDFM (M.intersection x (ufmToIntMap y)) i
+ -- M.intersection is left biased, that means the result will only have
+ -- a subset of elements from the left set, so `i` is a good upper bound.
+
intersectsUDFM :: UniqDFM elt -> UniqDFM elt -> Bool
intersectsUDFM x y = isNullUDFM (x `intersectUDFM` y)