diff options
Diffstat (limited to 'compiler/GHC/Core/TyCon/Set.hs')
-rw-r--r-- | compiler/GHC/Core/TyCon/Set.hs | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/compiler/GHC/Core/TyCon/Set.hs b/compiler/GHC/Core/TyCon/Set.hs new file mode 100644 index 0000000000..40beac6c58 --- /dev/null +++ b/compiler/GHC/Core/TyCon/Set.hs @@ -0,0 +1,73 @@ +{- +(c) The University of Glasgow 2006 +(c) The GRASP/AQUA Project, Glasgow University, 1992-1998 + +-} + +{-# LANGUAGE CPP, DeriveDataTypeable #-} + +module GHC.Core.TyCon.Set ( + -- * TyCons set type + TyConSet, + + -- ** Manipulating these sets + emptyTyConSet, unitTyConSet, mkTyConSet, unionTyConSet, unionTyConSets, + minusTyConSet, elemTyConSet, extendTyConSet, extendTyConSetList, + delFromTyConSet, delListFromTyConSet, isEmptyTyConSet, filterTyConSet, + intersectsTyConSet, disjointTyConSet, intersectTyConSet, + nameSetAny, nameSetAll + ) where + +#include "HsVersions.h" + +import GHC.Prelude + +import GHC.Types.Unique.Set +import GHC.Core.TyCon (TyCon) + +type TyConSet = UniqSet TyCon + +emptyTyConSet :: TyConSet +unitTyConSet :: TyCon -> TyConSet +extendTyConSetList :: TyConSet -> [TyCon] -> TyConSet +extendTyConSet :: TyConSet -> TyCon -> TyConSet +mkTyConSet :: [TyCon] -> TyConSet +unionTyConSet :: TyConSet -> TyConSet -> TyConSet +unionTyConSets :: [TyConSet] -> TyConSet +minusTyConSet :: TyConSet -> TyConSet -> TyConSet +elemTyConSet :: TyCon -> TyConSet -> Bool +isEmptyTyConSet :: TyConSet -> Bool +delFromTyConSet :: TyConSet -> TyCon -> TyConSet +delListFromTyConSet :: TyConSet -> [TyCon] -> TyConSet +filterTyConSet :: (TyCon -> Bool) -> TyConSet -> TyConSet +intersectTyConSet :: TyConSet -> TyConSet -> TyConSet +intersectsTyConSet :: TyConSet -> TyConSet -> Bool +-- ^ True if there is a non-empty intersection. +-- @s1 `intersectsTyConSet` s2@ doesn't compute @s2@ if @s1@ is empty +disjointTyConSet :: TyConSet -> TyConSet -> Bool + +isEmptyTyConSet = isEmptyUniqSet +emptyTyConSet = emptyUniqSet +unitTyConSet = unitUniqSet +mkTyConSet = mkUniqSet +extendTyConSetList = addListToUniqSet +extendTyConSet = addOneToUniqSet +unionTyConSet = unionUniqSets +unionTyConSets = unionManyUniqSets +minusTyConSet = minusUniqSet +elemTyConSet = elementOfUniqSet +delFromTyConSet = delOneFromUniqSet +filterTyConSet = filterUniqSet +intersectTyConSet = intersectUniqSets +disjointTyConSet = disjointUniqSets + + +delListFromTyConSet set ns = foldl' delFromTyConSet set ns + +intersectsTyConSet s1 s2 = not (isEmptyTyConSet (s1 `intersectTyConSet` s2)) + +nameSetAny :: (TyCon -> Bool) -> TyConSet -> Bool +nameSetAny = uniqSetAny + +nameSetAll :: (TyCon -> Bool) -> TyConSet -> Bool +nameSetAll = uniqSetAll |