yhccore-0.9.1: Yhc's Internal Core language.



In: x -> y x

x is bound

y is free



collectAllVars :: CoreExpr -> [CoreVarName]Source

Which variables are mentioned in an expression

collectBoundVars :: CoreExpr -> [CoreVarName]Source

Which variables are introduced at any point, i.e. LHS of a case alternative, or by a let

collectFreeVars :: CoreExpr -> [CoreVarName]Source

Which variables are in the used in an expression before being defined. No variable will occur more than once

countFreeVar :: CoreVarName -> CoreExpr -> IntSource

Count the number of uses of a free variable. If a variable is used in different branches of a case, it is only considered to be the maximum of these two branches.

replaceFreeVars :: [(CoreVarName, CoreExpr)] -> CoreExpr -> CoreExprSource

Replace all free occurances of variables with a new expression

variableSupply :: Char -> [String]Source

Given a prefix, generate a stream of variables Each will be unique in the series

uniqueBoundVars :: CoreExpr -> CoreExprSource

Just uniqueFreeVarsWith, but with a default set of variables

uniqueBoundVarsWith :: [String] -> CoreExpr -> CoreExprSource

Replace all variables which are locally defined with new names from the given list. Raises an error if not enough free variables are supplied

If any in the new list clashes with a name in collectFreeVars this will return a program with different semantics!

Property: collectFreeVars (uniqueFreeVarsWith newvars x) subset newvars

uniqueBoundVarsWithout :: [String] -> CoreExpr -> CoreExprSource

Just uniqueFreeVarsWith, but with a certain set excluded

uniqueBoundVarsCore :: Core -> CoreSource

Make a whole Core program have unique free variables. Between functions, they may share variables

uniqueBoundVarsFunc :: CoreFunc -> CoreFuncSource

Make a whole function have unique free variables