GHC.Types.Var.Set

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

Safe Haskell | Ignore
Language | GHC2021

GHC.Types.Var.Set

Contents

- Var, Id and TyVar set types
  - Manipulating these sets
- Deterministic Var set types
  - Manipulating these sets

Synopsis

- type VarSet = UniqSet Var
- type IdSet = UniqSet Id
- type TyVarSet = UniqSet TyVar
- type CoVarSet = UniqSet CoVar
- type TyCoVarSet = UniqSet TyCoVar
- emptyVarSet :: VarSet
- unitVarSet :: Var -> VarSet
- mkVarSet :: [Var] -> VarSet
- extendVarSet :: VarSet -> Var -> VarSet
- extendVarSetList :: VarSet -> [Var] -> VarSet
- elemVarSet :: Var -> VarSet -> Bool
- subVarSet :: VarSet -> VarSet -> Bool
- unionVarSet :: VarSet -> VarSet -> VarSet
- unionVarSets :: [VarSet] -> VarSet
- mapUnionVarSet :: (a -> VarSet) -> [a] -> VarSet
- intersectVarSet :: VarSet -> VarSet -> VarSet
- intersectsVarSet :: VarSet -> VarSet -> Bool
- disjointVarSet :: VarSet -> VarSet -> Bool
- isEmptyVarSet :: VarSet -> Bool
- delVarSet :: VarSet -> Var -> VarSet
- delVarSetList :: VarSet -> [Var] -> VarSet
- delVarSetByKey :: VarSet -> Unique -> VarSet
- minusVarSet :: VarSet -> VarSet -> VarSet
- filterVarSet :: (Var -> Bool) -> VarSet -> VarSet
- mapVarSet :: Uniquable b => (a -> b) -> UniqSet a -> UniqSet b
- anyVarSet :: (Var -> Bool) -> VarSet -> Bool
- allVarSet :: (Var -> Bool) -> VarSet -> Bool
- transCloVarSet :: (VarSet -> VarSet) -> VarSet -> VarSet
- fixVarSet :: (VarSet -> VarSet) -> VarSet -> VarSet
- lookupVarSet_Directly :: VarSet -> Unique -> Maybe Var
- lookupVarSet :: VarSet -> Var -> Maybe Var
- lookupVarSetByName :: VarSet -> Name -> Maybe Var
- sizeVarSet :: VarSet -> Int
- seqVarSet :: VarSet -> ()
- elemVarSetByKey :: Unique -> VarSet -> Bool
- partitionVarSet :: (Var -> Bool) -> VarSet -> (VarSet, VarSet)
- pluralVarSet :: VarSet -> SDoc
- pprVarSet :: VarSet -> ([Var] -> SDoc) -> SDoc
- nonDetStrictFoldVarSet :: (Var -> a -> a) -> a -> VarSet -> a
- type DVarSet = UniqDSet Var
- type DIdSet = UniqDSet Id
- type DTyVarSet = UniqDSet TyVar
- type DTyCoVarSet = UniqDSet TyCoVar
- emptyDVarSet :: DVarSet
- unitDVarSet :: Var -> DVarSet
- mkDVarSet :: [Var] -> DVarSet
- extendDVarSet :: DVarSet -> Var -> DVarSet
- extendDVarSetList :: DVarSet -> [Var] -> DVarSet
- elemDVarSet :: Var -> DVarSet -> Bool
- dVarSetElems :: DVarSet -> [Var]
- subDVarSet :: DVarSet -> DVarSet -> Bool
- unionDVarSet :: DVarSet -> DVarSet -> DVarSet
- unionDVarSets :: [DVarSet] -> DVarSet
- mapUnionDVarSet :: (a -> DVarSet) -> [a] -> DVarSet
- intersectDVarSet :: DVarSet -> DVarSet -> DVarSet
- dVarSetIntersectVarSet :: DVarSet -> VarSet -> DVarSet
- intersectsDVarSet :: DVarSet -> DVarSet -> Bool
- disjointDVarSet :: DVarSet -> DVarSet -> Bool
- isEmptyDVarSet :: DVarSet -> Bool
- delDVarSet :: DVarSet -> Var -> DVarSet
- delDVarSetList :: DVarSet -> [Var] -> DVarSet
- minusDVarSet :: DVarSet -> DVarSet -> DVarSet
- nonDetStrictFoldDVarSet :: (Var -> a -> a) -> a -> DVarSet -> a
- filterDVarSet :: (Var -> Bool) -> DVarSet -> DVarSet
- mapDVarSet :: Uniquable b => (a -> b) -> UniqDSet a -> UniqDSet b
- dVarSetMinusVarSet :: DVarSet -> VarSet -> DVarSet
- anyDVarSet :: (Var -> Bool) -> DVarSet -> Bool
- allDVarSet :: (Var -> Bool) -> DVarSet -> Bool
- transCloDVarSet :: (DVarSet -> DVarSet) -> DVarSet -> DVarSet
- sizeDVarSet :: DVarSet -> Int
- seqDVarSet :: DVarSet -> ()
- partitionDVarSet :: (Var -> Bool) -> DVarSet -> (DVarSet, DVarSet)
- dVarSetToVarSet :: DVarSet -> VarSet

# Var, Id and TyVar set types

type VarSet = UniqSet Var #

A non-deterministic Variable Set

A non-deterministic set of variables. See Note [Deterministic UniqFM] in GHC.Types.Unique.DFM for explanation why it's not deterministic and why it matters. Use DVarSet if the set eventually gets converted into a list or folded over in a way where the order changes the generated code, for example when abstracting variables.

type IdSet = UniqSet Id #

Identifier Set

type TyVarSet = UniqSet TyVar #

Type Variable Set

type CoVarSet = UniqSet CoVar #

Coercion Variable Set

type TyCoVarSet = UniqSet TyCoVar #

Type or Coercion Variable Set

## Manipulating these sets

emptyVarSet :: VarSet #

unitVarSet :: Var -> VarSet #

mkVarSet :: [Var] -> VarSet #

extendVarSet :: VarSet -> Var -> VarSet #

extendVarSetList :: VarSet -> [Var] -> VarSet #

elemVarSet :: Var -> VarSet -> Bool #

subVarSet :: VarSet -> VarSet -> Bool #

unionVarSet :: VarSet -> VarSet -> VarSet #

unionVarSets :: [VarSet] -> VarSet #

mapUnionVarSet :: (a -> VarSet) -> [a] -> VarSet #

map the function over the list, and union the results

intersectVarSet :: VarSet -> VarSet -> VarSet #

intersectsVarSet :: VarSet -> VarSet -> Bool #

disjointVarSet :: VarSet -> VarSet -> Bool #

isEmptyVarSet :: VarSet -> Bool #

delVarSet :: VarSet -> Var -> VarSet #

delVarSetList :: VarSet -> [Var] -> VarSet #

delVarSetByKey :: VarSet -> Unique -> VarSet #

minusVarSet :: VarSet -> VarSet -> VarSet #

filterVarSet :: (Var -> Bool) -> VarSet -> VarSet #

mapVarSet :: Uniquable b => (a -> b) -> UniqSet a -> UniqSet b #

anyVarSet :: (Var -> Bool) -> VarSet -> Bool #

allVarSet :: (Var -> Bool) -> VarSet -> Bool #

transCloVarSet :: (VarSet -> VarSet) -> VarSet -> VarSet #

fixVarSet :: (VarSet -> VarSet) -> VarSet -> VarSet #

lookupVarSet_Directly :: VarSet -> Unique -> Maybe Var #

lookupVarSet :: VarSet -> Var -> Maybe Var #

lookupVarSetByName :: VarSet -> Name -> Maybe Var #

sizeVarSet :: VarSet -> Int #

seqVarSet :: VarSet -> () #

elemVarSetByKey :: Unique -> VarSet -> Bool #

partitionVarSet :: (Var -> Bool) -> VarSet -> (VarSet, VarSet) #

pluralVarSet :: VarSet -> SDoc #

Determines the pluralisation suffix appropriate for the length of a set in the same way that plural from Outputable does for lists.

pprVarSet #

Arguments

:: VarSet | The things to be pretty printed
-> ([Var] -> SDoc) | The pretty printing function to use on the elements
-> SDoc | `SDoc` where the things have been pretty printed

Pretty-print a non-deterministic set. The order of variables is non-deterministic and for pretty-printing that shouldn't be a problem. Having this function helps contain the non-determinism created with nonDetEltsUFM. Passing a list to the pretty-printing function allows the caller to decide on the order of Vars (eg. toposort them) without them having to use nonDetEltsUFM at the call site. This prevents from let-binding non-deterministically ordered lists and reusing them where determinism matters.

nonDetStrictFoldVarSet :: (Var -> a -> a) -> a -> VarSet -> a #

# Deterministic Var set types

type DVarSet = UniqDSet Var #

Deterministic Variable Set

type DIdSet = UniqDSet Id #

Deterministic Identifier Set

type DTyVarSet = UniqDSet TyVar #

Deterministic Type Variable Set

type DTyCoVarSet = UniqDSet TyCoVar #

Deterministic Type or Coercion Variable Set

## Manipulating these sets

emptyDVarSet :: DVarSet #

unitDVarSet :: Var -> DVarSet #

mkDVarSet :: [Var] -> DVarSet #

extendDVarSet :: DVarSet -> Var -> DVarSet #

extendDVarSetList :: DVarSet -> [Var] -> DVarSet #

Add a list of variables to DVarSet

elemDVarSet :: Var -> DVarSet -> Bool #

dVarSetElems :: DVarSet -> [Var] #

subDVarSet :: DVarSet -> DVarSet -> Bool #

unionDVarSet :: DVarSet -> DVarSet -> DVarSet #

unionDVarSets :: [DVarSet] -> DVarSet #

mapUnionDVarSet :: (a -> DVarSet) -> [a] -> DVarSet #

Map the function over the list, and union the results

intersectDVarSet :: DVarSet -> DVarSet -> DVarSet #

dVarSetIntersectVarSet :: DVarSet -> VarSet -> DVarSet #

intersectsDVarSet :: DVarSet -> DVarSet -> Bool #

True if non-empty intersection

disjointDVarSet :: DVarSet -> DVarSet -> Bool #

True if empty intersection

isEmptyDVarSet :: DVarSet -> Bool #

delDVarSet :: DVarSet -> Var -> DVarSet #

delDVarSetList :: DVarSet -> [Var] -> DVarSet #

Delete a list of variables from DVarSet

minusDVarSet :: DVarSet -> DVarSet -> DVarSet #

nonDetStrictFoldDVarSet :: (Var -> a -> a) -> a -> DVarSet -> a #

filterDVarSet :: (Var -> Bool) -> DVarSet -> DVarSet #

mapDVarSet :: Uniquable b => (a -> b) -> UniqDSet a -> UniqDSet b #

dVarSetMinusVarSet :: DVarSet -> VarSet -> DVarSet #

anyDVarSet :: (Var -> Bool) -> DVarSet -> Bool #

allDVarSet :: (Var -> Bool) -> DVarSet -> Bool #

transCloDVarSet :: (DVarSet -> DVarSet) -> DVarSet -> DVarSet #

transCloVarSet for DVarSet

sizeDVarSet :: DVarSet -> Int #

seqDVarSet :: DVarSet -> () #

partitionDVarSet :: (Var -> Bool) -> DVarSet -> (DVarSet, DVarSet) #

Partition DVarSet according to the predicate given

dVarSetToVarSet :: DVarSet -> VarSet #

Convert a DVarSet to a VarSet by forgetting the order of insertion