ghc-8.0.2: The GHC API

Safe Haskell | None
Language | Haskell2010

CoreFVs

Contents

- Free variables of expressions and binding groups
- Selective free variables of expressions
- Free variables of Rules, Vars and Ids
- Orphan names
- Core syntax tree annotation with free variables

Description

A module concerned with finding the free variables of an expression.

Synopsis

- exprFreeVars :: CoreExpr -> VarSet
- exprFreeVarsDSet :: CoreExpr -> DVarSet
- exprFreeVarsList :: CoreExpr -> [Var]
- exprFreeIds :: CoreExpr -> IdSet
- exprFreeIdsDSet :: CoreExpr -> DIdSet
- exprFreeIdsList :: CoreExpr -> [Id]
- exprsFreeIdsDSet :: [CoreExpr] -> DIdSet
- exprsFreeIdsList :: [CoreExpr] -> [Id]
- exprsFreeVars :: [CoreExpr] -> VarSet
- exprsFreeVarsList :: [CoreExpr] -> [Var]
- bindFreeVars :: CoreBind -> VarSet
- type InterestingVarFun = Var -> Bool
- exprSomeFreeVars :: InterestingVarFun -> CoreExpr -> VarSet
- exprsSomeFreeVars :: InterestingVarFun -> [CoreExpr] -> VarSet
- exprSomeFreeVarsList :: InterestingVarFun -> CoreExpr -> [Var]
- exprsSomeFreeVarsList :: InterestingVarFun -> [CoreExpr] -> [Var]
- varTypeTyCoVars :: Var -> TyCoVarSet
- varTypeTyCoFVs :: Var -> FV
- idUnfoldingVars :: Id -> VarSet
- idFreeVars :: Id -> VarSet
- dIdFreeVars :: Id -> DVarSet
- idRuleAndUnfoldingVars :: Id -> VarSet
- idRuleAndUnfoldingVarsDSet :: Id -> DVarSet
- idFVs :: Id -> FV
- idRuleVars :: Id -> VarSet
- idRuleRhsVars :: (Activation -> Bool) -> Id -> VarSet
- stableUnfoldingVars :: Unfolding -> Maybe VarSet
- ruleRhsFreeVars :: CoreRule -> VarSet
- ruleFreeVars :: CoreRule -> VarSet
- rulesFreeVars :: [CoreRule] -> VarSet
- rulesFreeVarsDSet :: [CoreRule] -> DVarSet
- ruleLhsFreeIds :: CoreRule -> VarSet
- ruleLhsFreeIdsList :: CoreRule -> [Var]
- vectsFreeVars :: [CoreVect] -> VarSet
- expr_fvs :: CoreExpr -> FV
- orphNamesOfType :: Type -> NameSet
- orphNamesOfCo :: Coercion -> NameSet
- orphNamesOfAxiom :: CoAxiom br -> NameSet
- orphNamesOfTypes :: [Type] -> NameSet
- orphNamesOfCoCon :: CoAxiom br -> NameSet
- exprsOrphNames :: [CoreExpr] -> NameSet
- orphNamesOfFamInst :: FamInst -> NameSet
- data FVAnn
- type CoreExprWithFVs = AnnExpr Id FVAnn
- type CoreExprWithFVs' = AnnExpr' Id FVAnn
- type CoreBindWithFVs = AnnBind Id FVAnn
- type CoreAltWithFVs = AnnAlt Id FVAnn
- freeVars :: CoreExpr -> CoreExprWithFVs
- freeVarsOf :: CoreExprWithFVs -> DIdSet
- freeVarsOfType :: CoreExprWithFVs -> DTyCoVarSet
- freeVarsOfAnn :: FVAnn -> DIdSet
- freeVarsOfTypeAnn :: FVAnn -> DTyCoVarSet
- exprTypeFV :: CoreExprWithFVs -> Type

# Free variables of expressions and binding groups

exprFreeVars :: CoreExpr -> VarSet Source #

Find all locally-defined free Ids or type variables in an expression returning a non-deterministic set.

exprFreeVarsDSet :: CoreExpr -> DVarSet Source #

Find all locally-defined free Ids or type variables in an expression returning a deterministic set.

exprFreeVarsList :: CoreExpr -> [Var] Source #

Find all locally-defined free Ids or type variables in an expression returning a deterministically ordered list.

exprFreeIds :: CoreExpr -> IdSet Source #

Find all locally-defined free Ids in an expression

exprFreeIdsDSet :: CoreExpr -> DIdSet Source #

Find all locally-defined free Ids in an expression returning a deterministic set.

exprFreeIdsList :: CoreExpr -> [Id] Source #

Find all locally-defined free Ids in an expression returning a deterministically ordered list.

exprsFreeIdsDSet :: [CoreExpr] -> DIdSet Source #

Find all locally-defined free Ids in several expressions returning a deterministic set.

exprsFreeIdsList :: [CoreExpr] -> [Id] Source #

Find all locally-defined free Ids in several expressions returning a deterministically ordered list.

exprsFreeVars :: [CoreExpr] -> VarSet Source #

Find all locally-defined free Ids or type variables in several expressions returning a non-deterministic set.

exprsFreeVarsList :: [CoreExpr] -> [Var] Source #

Find all locally-defined free Ids or type variables in several expressions returning a deterministically ordered list.

bindFreeVars :: CoreBind -> VarSet Source #

Find all locally defined free Ids in a binding group

# Selective free variables of expressions

type InterestingVarFun = Var -> Bool Source #

Predicate on possible free variables: returns `True` iff the variable is interesting

exprSomeFreeVars Source #

Arguments

:: InterestingVarFun | Says which `Var`s are interesting
-> CoreExpr |
-> VarSet |

Finds free variables in an expression selected by a predicate

exprsSomeFreeVars :: InterestingVarFun -> [CoreExpr] -> VarSet Source #

Finds free variables in several expressions selected by a predicate

exprSomeFreeVarsList Source #

Arguments

:: InterestingVarFun | Says which `Var`s are interesting
-> CoreExpr |
-> [Var] |

Finds free variables in an expression selected by a predicate returning a deterministically ordered list.

exprsSomeFreeVarsList :: InterestingVarFun -> [CoreExpr] -> [Var] Source #

Finds free variables in several expressions selected by a predicate returning a deterministically ordered list.

# Free variables of Rules, Vars and Ids

varTypeTyCoVars :: Var -> TyCoVarSet Source #

varTypeTyCoFVs :: Var -> FV Source #

idUnfoldingVars :: Id -> VarSet Source #

idFreeVars :: Id -> VarSet Source #

dIdFreeVars :: Id -> DVarSet Source #

idRuleAndUnfoldingVars :: Id -> VarSet Source #

idRuleAndUnfoldingVarsDSet :: Id -> DVarSet Source #

idFVs :: Id -> FV Source #

idRuleVars :: Id -> VarSet Source #

idRuleRhsVars :: (Activation -> Bool) -> Id -> VarSet Source #

stableUnfoldingVars :: Unfolding -> Maybe VarSet Source #

ruleRhsFreeVars :: CoreRule -> VarSet Source #

Those variables free in the right hand side of a rule returned as a non-deterministic set

ruleFreeVars :: CoreRule -> VarSet Source #

Those variables free in the both the left right hand sides of a rule returned as a non-deterministic set

rulesFreeVars :: [CoreRule] -> VarSet Source #

Those variables free in the right hand side of several rules

rulesFreeVarsDSet :: [CoreRule] -> DVarSet Source #

Those variables free in the both the left right hand sides of rules returned as a deterministic set

ruleLhsFreeIds :: CoreRule -> VarSet Source #

This finds all locally-defined free Ids on the left hand side of a rule and returns them as a non-deterministic set

ruleLhsFreeIdsList :: CoreRule -> [Var] Source #

This finds all locally-defined free Ids on the left hand side of a rule and returns them as a determinisitcally ordered list

vectsFreeVars :: [CoreVect] -> VarSet Source #

Free variables of a vectorisation declaration

expr_fvs :: CoreExpr -> FV Source #

# Orphan names

orphNamesOfType :: Type -> NameSet Source #

orphNamesOfCo :: Coercion -> NameSet Source #

orphNamesOfAxiom :: CoAxiom br -> NameSet Source #

orphNamesOfTypes :: [Type] -> NameSet Source #

orphNamesOfCoCon :: CoAxiom br -> NameSet Source #

exprsOrphNames :: [CoreExpr] -> NameSet Source #

Finds the free external names of several expressions: see `exprOrphNames` for details

orphNamesOfFamInst :: FamInst -> NameSet Source #

orphNamesOfAxiom collects the names of the concrete types and type constructors that make up the LHS of a type family instance, including the family name itself.

For instance, given `type family Foo a b`: `type instance Foo (F (G (H a))) b = ...` would yield [Foo,F,G,H]

Used in the implementation of ":info" in GHCi.

# Core syntax tree annotation with free variables

data FVAnn Source #

type CoreExprWithFVs = AnnExpr Id FVAnn Source #

Every node in an expression annotated with its (non-global) free variables, both Ids and TyVars, and type.

type CoreExprWithFVs' = AnnExpr' Id FVAnn Source #

type CoreBindWithFVs = AnnBind Id FVAnn Source #

Every node in a binding group annotated with its (non-global) free variables, both Ids and TyVars, and type.

type CoreAltWithFVs = AnnAlt Id FVAnn Source #

Every node in an expression annotated with its (non-global) free variables, both Ids and TyVars, and type.

freeVars :: CoreExpr -> CoreExprWithFVs Source #

Annotate a `CoreExpr` with its (non-global) free type and value variables at every tree node

freeVarsOf :: CoreExprWithFVs -> DIdSet Source #

Inverse function to `freeVars`

freeVarsOfType :: CoreExprWithFVs -> DTyCoVarSet Source #

Extract the vars free in an annotated expression's type

freeVarsOfAnn :: FVAnn -> DIdSet Source #

Extract the vars reported in a FVAnn

freeVarsOfTypeAnn :: FVAnn -> DTyCoVarSet Source #

Extract the type-level vars reported in a FVAnn

exprTypeFV :: CoreExprWithFVs -> Type Source #

Extract the type of an annotated expression. (This is cheap.)