GHC.Utils.FV
Utilities for efficiently and deterministically computing free variables.
Deterministic free vars computations
type FV = InterestingVarFun -> VarSet -> VarAcc -> VarAcc Source #
type InterestingVarFun = Var -> Bool Source #
Predicate on possible free variables: returns True
iff the variable is
interesting
Running the computations
fvVarList :: FV -> [Var] Source #
Run a free variable computation, returning a list of distinct free variables in deterministic order.
fvVarSet :: FV -> VarSet Source #
Run a free variable computation, returning a non-deterministic set of free variables. Don't use if the set will be later converted to a list and the order of that list will impact the generated code.
fvDVarSet :: FV -> DVarSet Source #
Run a free variable computation, returning a deterministic set of free
variables. Note that this is just a wrapper around the version that
returns a deterministic list. If you need a list you should use
fvVarList
.
Manipulating those computations
Add a variable - when free, to the returned free variables. Ignores duplicates and respects the filtering function.
Add multiple variables - when free, to the returned free variables. Ignores duplicates and respects the filtering function.
mapUnionFV :: (a -> FV) -> [a] -> FV Source #
Map a free variable computation over a list and union the results.