summaryrefslogtreecommitdiff
path: root/compiler/utils/UniqDSet.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/utils/UniqDSet.hs')
-rw-r--r--compiler/utils/UniqDSet.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/utils/UniqDSet.hs b/compiler/utils/UniqDSet.hs
index 92d924ee37..c2ace5787f 100644
--- a/compiler/utils/UniqDSet.hs
+++ b/compiler/utils/UniqDSet.hs
@@ -33,7 +33,8 @@ module UniqDSet (
isEmptyUniqDSet,
lookupUniqDSet,
uniqDSetToList,
- partitionUniqDSet
+ partitionUniqDSet,
+ mapUniqDSet
) where
import GhcPrelude
@@ -121,6 +122,10 @@ uniqDSetToList = eltsUDFM . getUniqDSet
partitionUniqDSet :: (a -> Bool) -> UniqDSet a -> (UniqDSet a, UniqDSet a)
partitionUniqDSet p = coerce . partitionUDFM p . getUniqDSet
+-- See Note [UniqSet invariant] in UniqSet.hs
+mapUniqDSet :: Uniquable b => (a -> b) -> UniqDSet a -> UniqDSet b
+mapUniqDSet f = mkUniqDSet . map f . uniqDSetToList
+
-- Two 'UniqDSet's are considered equal if they contain the same
-- uniques.
instance Eq (UniqDSet a) where