diff options
| author | Bartosz Nitka <niteria@gmail.com> | 2016-06-30 08:20:41 -0700 |
|---|---|---|
| committer | Bartosz Nitka <niteria@gmail.com> | 2016-06-30 10:22:41 -0700 |
| commit | 480e0661fb45395610d6b4a7c586a580d30d8df4 (patch) | |
| tree | cc4a0effeaa3a46ea370496fb2a2143448b168f6 /compiler/utils/UniqFM.hs | |
| parent | b6b20a5074ad7d712b4d8448043fc25e4c7bcdaa (diff) | |
| download | haskell-480e0661fb45395610d6b4a7c586a580d30d8df4.tar.gz | |
Remove ufmToList
This documents nondeterminism in code generation and removes
the nondeterministic ufmToList function. In the future someone
will have to use nonDetUFMToList (with proper explanation)
or pprUFMWithKeys.
Diffstat (limited to 'compiler/utils/UniqFM.hs')
| -rw-r--r-- | compiler/utils/UniqFM.hs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/compiler/utils/UniqFM.hs b/compiler/utils/UniqFM.hs index f9832d5455..261dd1c622 100644 --- a/compiler/utils/UniqFM.hs +++ b/compiler/utils/UniqFM.hs @@ -64,8 +64,8 @@ module UniqFM ( lookupWithDefaultUFM, lookupWithDefaultUFM_Directly, nonDetEltsUFM, eltsUFM, nonDetKeysUFM, ufmToSet_Directly, - nonDetUFMToList, ufmToList, ufmToIntMap, - pprUniqFM, pprUFM, pluralUFM + nonDetUFMToList, ufmToIntMap, + pprUniqFM, pprUFM, pprUFMWithKeys, pluralUFM ) where import Unique ( Uniquable(..), Unique, getKey ) @@ -184,7 +184,6 @@ lookupWithDefaultUFM_Directly :: UniqFM elt -> elt -> Unique -> elt eltsUFM :: UniqFM elt -> [elt] ufmToSet_Directly :: UniqFM elt -> S.IntSet -ufmToList :: UniqFM elt -> [(Unique, elt)] {- ************************************************************************ @@ -286,7 +285,6 @@ lookupWithDefaultUFM (UFM m) v k = M.findWithDefault v (getKey $ getUnique k) m lookupWithDefaultUFM_Directly (UFM m) v u = M.findWithDefault v (getKey u) m eltsUFM (UFM m) = M.elems m ufmToSet_Directly (UFM m) = M.keysSet m -ufmToList (UFM m) = map (\(k, v) -> (getUnique k, v)) $ M.toList m anyUFM :: (elt -> Bool) -> UniqFM elt -> Bool anyUFM p (UFM m) = M.fold ((||) . p) False m @@ -357,6 +355,18 @@ pprUFM :: UniqFM a -- ^ The things to be pretty printed -- printed pprUFM ufm pp = pp (nonDetEltsUFM ufm) +-- | Pretty-print a non-deterministic set. +-- The order of variables is non-deterministic and for pretty-printing that +-- shouldn't be a problem. +-- Having this function helps contain the non-determinism created with +-- nonDetUFMToList. +pprUFMWithKeys + :: UniqFM a -- ^ The things to be pretty printed + -> ([(Unique, a)] -> SDoc) -- ^ The pretty printing function to use on the elements + -> SDoc -- ^ 'SDoc' where the things have been pretty + -- printed +pprUFMWithKeys ufm pp = pp (nonDetUFMToList ufm) + -- | Determines the pluralisation suffix appropriate for the length of a set -- in the same way that plural from Outputable does for lists. pluralUFM :: UniqFM a -> SDoc |
