    {-
    (c) The University of Glasgow 2006
    (c) The GRASP/AQUA Project, Glasgow University, 1992-1998

    -}

    {-# LANGUAGE CPP #-}

    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 :: TyConSet -> Bool
    isEmptyTyConSet    = forall a. UniqSet a -> Bool
    isEmptyUniqSet
    emptyTyConSet :: TyConSet
    emptyTyConSet      = forall a. UniqSet a
    emptyUniqSet
    unitTyConSet :: TyCon -> TyConSet
    unitTyConSet       = forall a. Uniquable a => a -> UniqSet a
    unitUniqSet
    mkTyConSet :: [TyCon] -> TyConSet
    mkTyConSet         = forall a. Uniquable a => [a] -> UniqSet a
    mkUniqSet
    extendTyConSetList :: TyConSet -> [TyCon] -> TyConSet
    extendTyConSetList = forall a. Uniquable a => UniqSet a -> [a] -> UniqSet a
    addListToUniqSet
    extendTyConSet :: TyConSet -> TyCon -> TyConSet
    extendTyConSet     = forall a. Uniquable a => UniqSet a -> a -> UniqSet a
    addOneToUniqSet
    unionTyConSet :: TyConSet -> TyConSet -> TyConSet
    unionTyConSet      = forall a. UniqSet a -> UniqSet a -> UniqSet a
    unionUniqSets
    unionTyConSets :: [TyConSet] -> TyConSet
    unionTyConSets     = forall a. [UniqSet a] -> UniqSet a
    unionManyUniqSets
    minusTyConSet :: TyConSet -> TyConSet -> TyConSet
    minusTyConSet      = forall a. UniqSet a -> UniqSet a -> UniqSet a
    minusUniqSet
    elemTyConSet :: TyCon -> TyConSet -> Bool
    elemTyConSet       = forall a. Uniquable a => a -> UniqSet a -> Bool
    elementOfUniqSet
    delFromTyConSet :: TyConSet -> TyCon -> TyConSet
    delFromTyConSet    = forall a. Uniquable a => UniqSet a -> a -> UniqSet a
    delOneFromUniqSet
    filterTyConSet :: (TyCon -> Bool) -> TyConSet -> TyConSet
    filterTyConSet     = forall a. (a -> Bool) -> UniqSet a -> UniqSet a
    filterUniqSet
    intersectTyConSet :: TyConSet -> TyConSet -> TyConSet
    intersectTyConSet  = forall a. UniqSet a -> UniqSet a -> UniqSet a
    intersectUniqSets
    disjointTyConSet :: TyConSet -> TyConSet -> Bool
    disjointTyConSet   = forall a. UniqSet a -> UniqSet a -> Bool
    disjointUniqSets

    delListFromTyConSet :: TyConSet -> [TyCon] -> TyConSet
    delListFromTyConSet TyConSet
    set [TyCon]
    ns = forall (t :: * -> *) b a.
    Foldable t =>
    (b -> a -> b) -> b -> t a -> b
    foldl' TyConSet -> TyCon -> TyConSet
    delFromTyConSet TyConSet
    set [TyCon]
    ns

    intersectsTyConSet :: TyConSet -> TyConSet -> Bool
    intersectsTyConSet TyConSet
    s1 TyConSet
    s2 = Bool -> Bool
    not (TyConSet -> Bool
    isEmptyTyConSet (TyConSet
    s1 TyConSet -> TyConSet -> TyConSet
    `intersectTyConSet` TyConSet
    s2))

    nameSetAny :: (TyCon -> Bool) -> TyConSet -> Bool
    nameSetAny :: (TyCon -> Bool) -> TyConSet -> Bool
    nameSetAny = forall a. (a -> Bool) -> UniqSet a -> Bool
    uniqSetAny

    nameSetAll :: (TyCon -> Bool) -> TyConSet -> Bool
    nameSetAll :: (TyCon -> Bool) -> TyConSet -> Bool
    nameSetAll = forall a. (a -> Bool) -> UniqSet a -> Bool
    uniqSetAll