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.

uniplateBoundVars :: CoreExpr -> ([CoreVarName], [CoreVarName] -> CoreExpr)Source

Get the variables that are defined to one-level depth and a function to replace them

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

Replace all free occurances of variables with a new expression

checkFreeVar :: CoreExpr -> CoreExpr -> BoolSource

Check that the free variables in the second expression are also in the first one. It usually indicates an error to introduce new free variables in transformation.

Return True for safe, False for probably buggy.

uniqueBoundVarsCore :: UniqueIdM m => Core -> m CoreSource

Make a whole Core program have unique free variables.

uniqueBoundVarsFunc :: UniqueIdM m => CoreFunc -> m CoreFuncSource

Make a whole function have unique free variables

uniqueBoundVars :: UniqueIdM m => CoreExpr -> m CoreExprSource

Take care: If v123 is a free variable, then make sure getVar starts above that