From 3efa0623150111e8157141441ee5571452f8e139 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Tue, 5 Feb 2008 21:19:09 +0000 Subject: [PATCH] Be a bit more consistent about what's a set and what's a map --- compiler/basicTypes/OccName.lhs | 2 +- compiler/basicTypes/VarSet.lhs | 4 ++-- compiler/utils/UniqSet.lhs | 12 ++++++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/compiler/basicTypes/OccName.lhs b/compiler/basicTypes/OccName.lhs index 97d6857..c96cfd2 100644 --- a/compiler/basicTypes/OccName.lhs +++ b/compiler/basicTypes/OccName.lhs @@ -302,7 +302,7 @@ filterOccEnv x (A y) = A $ filterUFM x y instance Outputable a => Outputable (OccEnv a) where ppr (A x) = ppr x -type OccSet = UniqFM OccName +type OccSet = UniqSet OccName emptyOccSet :: OccSet unitOccSet :: OccName -> OccSet diff --git a/compiler/basicTypes/VarSet.lhs b/compiler/basicTypes/VarSet.lhs index 3c61225..1bef89a 100644 --- a/compiler/basicTypes/VarSet.lhs +++ b/compiler/basicTypes/VarSet.lhs @@ -95,8 +95,8 @@ lookupVarSet = lookupUniqSet mapVarSet = mapUniqSet sizeVarSet = sizeUniqSet filterVarSet = filterUniqSet -extendVarSet_C combine s x = addToUFM_C combine s x x -delVarSetByKey = delFromUFM_Directly -- Can't be bothered to add this to UniqSet +extendVarSet_C = addOneToUniqSet_C +delVarSetByKey = delOneFromUniqSet_Directly elemVarSetByKey = elemUniqSet_Directly \end{code} diff --git a/compiler/utils/UniqSet.lhs b/compiler/utils/UniqSet.lhs index ba312dd..90e0c9f 100644 --- a/compiler/utils/UniqSet.lhs +++ b/compiler/utils/UniqSet.lhs @@ -13,8 +13,8 @@ module UniqSet ( UniqSet, -- abstract type: NOT mkUniqSet, uniqSetToList, emptyUniqSet, unitUniqSet, - addOneToUniqSet, addListToUniqSet, - delOneFromUniqSet, delListFromUniqSet, + addOneToUniqSet, addListToUniqSet, addOneToUniqSet_C, + delOneFromUniqSet, delListFromUniqSet, delOneFromUniqSet_Directly, unionUniqSets, unionManyUniqSets, minusUniqSet, elementOfUniqSet, mapUniqSet, intersectUniqSets, isEmptyUniqSet, filterUniqSet, sizeUniqSet, foldUniqSet, @@ -65,9 +65,17 @@ mkUniqSet xs = MkUniqSet (listToUFM [ (x, x) | x <- xs]) addOneToUniqSet :: Uniquable a => UniqSet a -> a -> UniqSet a addOneToUniqSet (MkUniqSet set) x = MkUniqSet (addToUFM set x x) +addOneToUniqSet_C :: Uniquable a + => (a -> a -> a) -> UniqSet a -> a -> UniqSet a +addOneToUniqSet_C f (MkUniqSet set) x = MkUniqSet (addToUFM_C f set x x) + delOneFromUniqSet :: Uniquable a => UniqSet a -> a -> UniqSet a delOneFromUniqSet (MkUniqSet set) x = MkUniqSet (delFromUFM set x) +delOneFromUniqSet_Directly :: Uniquable a => UniqSet a -> Unique -> UniqSet a +delOneFromUniqSet_Directly (MkUniqSet set) u + = MkUniqSet (delFromUFM_Directly set u) + delListFromUniqSet :: Uniquable a => UniqSet a -> [a] -> UniqSet a delListFromUniqSet (MkUniqSet set) xs = MkUniqSet (delListFromUFM set xs) -- 1.7.10.4