[commit: ghc] master: Extend ModuleSet with useful functions (033f897)
git at git.haskell.org
git at git.haskell.org
Mon May 22 17:17:02 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/033f897a8ad34d62aff585d9df16c640bb55f21c/ghc
>---------------------------------------------------------------
commit 033f897a8ad34d62aff585d9df16c640bb55f21c
Author: Bartosz Nitka <niteria at gmail.com>
Date: Mon May 22 10:16:26 2017 -0700
Extend ModuleSet with useful functions
>---------------------------------------------------------------
033f897a8ad34d62aff585d9df16c640bb55f21c
compiler/basicTypes/Module.hs | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/compiler/basicTypes/Module.hs b/compiler/basicTypes/Module.hs
index 4a3212f..c693e7a 100644
--- a/compiler/basicTypes/Module.hs
+++ b/compiler/basicTypes/Module.hs
@@ -131,7 +131,10 @@ module Module
-- * Sets of Modules
ModuleSet,
- emptyModuleSet, mkModuleSet, moduleSetElts, extendModuleSet, elemModuleSet
+ emptyModuleSet, mkModuleSet, moduleSetElts,
+ extendModuleSet, extendModuleSetList,
+ elemModuleSet, intersectModuleSet, minusModuleSet, unionModuleSet,
+ unitModuleSet
) where
import Config
@@ -1255,6 +1258,9 @@ mkModuleSet = Set.fromList . coerce
extendModuleSet :: ModuleSet -> Module -> ModuleSet
extendModuleSet s m = Set.insert (NDModule m) s
+extendModuleSetList :: ModuleSet -> [Module] -> ModuleSet
+extendModuleSetList s ms = foldl' (coerce . flip Set.insert) s ms
+
emptyModuleSet :: ModuleSet
emptyModuleSet = Set.empty
@@ -1264,6 +1270,18 @@ moduleSetElts = sort . coerce . Set.toList
elemModuleSet :: Module -> ModuleSet -> Bool
elemModuleSet = Set.member . coerce
+intersectModuleSet :: ModuleSet -> ModuleSet -> ModuleSet
+intersectModuleSet = coerce Set.intersection
+
+minusModuleSet :: ModuleSet -> ModuleSet -> ModuleSet
+minusModuleSet = coerce Set.difference
+
+unionModuleSet :: ModuleSet -> ModuleSet -> ModuleSet
+unionModuleSet = coerce Set.union
+
+unitModuleSet :: Module -> ModuleSet
+unitModuleSet = coerce Set.singleton
+
{-
A ModuleName has a Unique, so we can build mappings of these using
UniqFM.
More information about the ghc-commits
mailing list