[commit: ghc] master: Add nameSetElemsStable and fix the build (3eac3a0)
git at git.haskell.org
git at git.haskell.org
Thu Jun 2 17:32:13 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/3eac3a0e9f74ad936375e3ba65f5d8454ea9d408/ghc
>---------------------------------------------------------------
commit 3eac3a0e9f74ad936375e3ba65f5d8454ea9d408
Author: Bartosz Nitka <niteria at gmail.com>
Date: Thu Jun 2 10:34:57 2016 -0700
Add nameSetElemsStable and fix the build
>---------------------------------------------------------------
3eac3a0e9f74ad936375e3ba65f5d8454ea9d408
compiler/basicTypes/NameSet.hs | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/compiler/basicTypes/NameSet.hs b/compiler/basicTypes/NameSet.hs
index 559f439..27a2c3b 100644
--- a/compiler/basicTypes/NameSet.hs
+++ b/compiler/basicTypes/NameSet.hs
@@ -13,7 +13,7 @@ module NameSet (
minusNameSet, elemNameSet, nameSetElems, extendNameSet, extendNameSetList,
delFromNameSet, delListFromNameSet, isEmptyNameSet, filterNameSet,
intersectsNameSet, intersectNameSet,
- nameSetAny, nameSetAll,
+ nameSetAny, nameSetAll, nameSetElemsStable,
-- * Free variables
FreeVars,
@@ -35,6 +35,8 @@ module NameSet (
import Name
import UniqSet
+import UniqFM
+import Data.List (sortBy)
{-
************************************************************************
@@ -90,6 +92,14 @@ nameSetAny = uniqSetAny
nameSetAll :: (Name -> Bool) -> NameSet -> Bool
nameSetAll = uniqSetAll
+-- | Get the elements of a NameSet with some stable ordering.
+-- See Note [Deterministic UniqFM] to learn about nondeterminism
+nameSetElemsStable :: NameSet -> [Name]
+nameSetElemsStable ns =
+ sortBy stableNameCmp $ nonDetEltsUFM ns
+ -- It's OK to use nonDetEltsUFM here because we immediately sort
+ -- with stableNameCmp
+
{-
************************************************************************
* *
More information about the ghc-commits
mailing list