GHC.Types.Name.Set

ghc-lib-parser-9.14.1.20251220: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Types.Name.Set

Contents

- Names set type
  - Manipulating these sets
- Free variables
  - Manipulating sets of free variables
- Defs and uses
  - Manipulating defs and uses
- Non-CAFfy names

Synopsis

- type NameSet = UniqSet Name
- emptyNameSet :: NameSet
- unitNameSet :: Name -> NameSet
- mkNameSet :: [Name] -> NameSet
- unionNameSet :: NameSet -> NameSet -> NameSet
- unionNameSets :: [NameSet] -> NameSet
- minusNameSet :: NameSet -> NameSet -> NameSet
- elemNameSet :: Name -> NameSet -> Bool
- extendNameSet :: NameSet -> Name -> NameSet
- extendNameSetList :: NameSet -> [Name] -> NameSet
- delFromNameSet :: NameSet -> Name -> NameSet
- delListFromNameSet :: NameSet -> [Name] -> NameSet
- isEmptyNameSet :: NameSet -> Bool
- filterNameSet :: (Name -> Bool) -> NameSet -> NameSet
- intersectsNameSet :: NameSet -> NameSet -> Bool
- disjointNameSet :: NameSet -> NameSet -> Bool
- intersectNameSet :: NameSet -> NameSet -> NameSet
- nameSetAny :: (Name -> Bool) -> NameSet -> Bool
- nameSetAll :: (Name -> Bool) -> NameSet -> Bool
- nameSetElemsStable :: NameSet -> [Name]
- type FreeVars = NameSet
- isEmptyFVs :: NameSet -> Bool
- emptyFVs :: FreeVars
- plusFVs :: [FreeVars] -> FreeVars
- plusFV :: FreeVars -> FreeVars -> FreeVars
- mkFVs :: [Name] -> FreeVars
- addOneFV :: FreeVars -> Name -> FreeVars
- unitFV :: Name -> FreeVars
- delFV :: Name -> FreeVars -> FreeVars
- delFVs :: [Name] -> FreeVars -> FreeVars
- intersectFVs :: FreeVars -> FreeVars -> FreeVars
- intersectsFVs :: FreeVars -> FreeVars -> Bool
- type Defs = NameSet
- type Uses = NameSet
- type DefUse = (Maybe Defs, Uses)
- type DefUses = OrdList DefUse
- emptyDUs :: DefUses
- usesOnly :: Uses -> DefUses
- mkDUs :: [(Defs, Uses)] -> DefUses
- plusDU :: DefUses -> DefUses -> DefUses
- findUses :: DefUses -> Uses -> Uses
- duDefs :: DefUses -> Defs
- duUses :: DefUses -> Uses
- allUses :: DefUses -> Uses
- newtype NonCaffySet = NonCaffySet {
  - ncs_nameSet :: NameSet
  }

# Names set type

type NameSet = UniqSet Name #

## Manipulating these sets

emptyNameSet :: NameSet #

unitNameSet :: Name -> NameSet #

mkNameSet :: [Name] -> NameSet #

unionNameSet :: NameSet -> NameSet -> NameSet #

unionNameSets :: [NameSet] -> NameSet #

minusNameSet :: NameSet -> NameSet -> NameSet #

elemNameSet :: Name -> NameSet -> Bool #

extendNameSet :: NameSet -> Name -> NameSet #

extendNameSetList :: NameSet -> [Name] -> NameSet #

delFromNameSet :: NameSet -> Name -> NameSet #

delListFromNameSet :: NameSet -> [Name] -> NameSet #

isEmptyNameSet :: NameSet -> Bool #

filterNameSet :: (Name -> Bool) -> NameSet -> NameSet #

intersectsNameSet :: NameSet -> NameSet -> Bool #

disjointNameSet :: NameSet -> NameSet -> Bool #

True if there is a non-empty intersection. `s1 `intersectsNameSet` s2` doesn't compute `s2` if `s1` is empty

intersectNameSet :: NameSet -> NameSet -> NameSet #

nameSetAny :: (Name -> Bool) -> NameSet -> Bool #

nameSetAll :: (Name -> Bool) -> NameSet -> Bool #

nameSetElemsStable :: NameSet -> [Name] #

Get the elements of a NameSet with some stable ordering. This only works for Names that originate in the source code or have been tidied. See Note [Deterministic UniqFM] to learn about nondeterminism

# Free variables

type FreeVars = NameSet #

## Manipulating sets of free variables

isEmptyFVs :: NameSet -> Bool #

emptyFVs :: FreeVars #

plusFVs :: [FreeVars] -> FreeVars #

plusFV :: FreeVars -> FreeVars -> FreeVars #

mkFVs :: [Name] -> FreeVars #

addOneFV :: FreeVars -> Name -> FreeVars #

unitFV :: Name -> FreeVars #

delFV :: Name -> FreeVars -> FreeVars #

delFVs :: [Name] -> FreeVars -> FreeVars #

intersectFVs :: FreeVars -> FreeVars -> FreeVars #

intersectsFVs :: FreeVars -> FreeVars -> Bool #

# Defs and uses

type Defs = NameSet #

A set of names that are defined somewhere

type Uses = NameSet #

A set of names that are used somewhere

type DefUse = (Maybe Defs, Uses) #

`(Just ds, us) =>` The use of any member of the `ds` implies that all the `us` are used too. Also, `us` may mention `ds`.

`Nothing =>` Nothing is defined in this group, but nevertheless all the uses are essential. Used for instance declarations, for example

type DefUses = OrdList DefUse #

A number of `DefUse`s in dependency order: earlier `Defs` scope over later `Uses` In a single (def, use) pair, the defs also scope over the uses

## Manipulating defs and uses

emptyDUs :: DefUses #

usesOnly :: Uses -> DefUses #

mkDUs :: [(Defs, Uses)] -> DefUses #

plusDU :: DefUses -> DefUses -> DefUses #

findUses :: DefUses -> Uses -> Uses #

Given some `DefUses` and some `Uses`, find all the uses, transitively. The result is a superset of the input `Uses`; and includes things defined in the input `DefUses` (but only if they are used)

duDefs :: DefUses -> Defs #

duUses :: DefUses -> Uses #

Collect all `Uses`, regardless of whether the group is itself used, but remove `Defs` on the way

allUses :: DefUses -> Uses #

Just like `duUses`, but `Defs` are not eliminated from the `Uses` returned

# Non-CAFfy names

newtype NonCaffySet #

`Id`s which have no CAF references. This is a result of analysis of C--. It is always safe to use an empty `NonCaffySet`. TODO Refer to Note.

Constructors

NonCaffySet |
Fields ncs_nameSet :: NameSet

#### Instances

Instances details

Monoid NonCaffySet # |
Instance details Defined in GHC.Types.Name.Set Methods mempty :: NonCaffySet # mappend :: NonCaffySet -> NonCaffySet -> NonCaffySet # mconcat :: [NonCaffySet] -> NonCaffySet #
Semigroup NonCaffySet # |
Instance details Defined in GHC.Types.Name.Set Methods (<>) :: NonCaffySet -> NonCaffySet -> NonCaffySet # sconcat :: NonEmpty NonCaffySet -> NonCaffySet # stimes :: Integral b => b -> NonCaffySet -> NonCaffySet #