In: x -> y x
x is bound
y is free
- collectAllVars :: CoreExpr -> [CoreVarName]
- collectBoundVars :: CoreExpr -> [CoreVarName]
- collectFreeVars :: CoreExpr -> [CoreVarName]
- countFreeVar :: CoreVarName -> CoreExpr -> Int
- uniplateBoundVars :: CoreExpr -> ([CoreVarName], [CoreVarName] -> CoreExpr)
- replaceFreeVars :: [(CoreVarName, CoreExpr)] -> CoreExpr -> CoreExpr
- replaceFreeVarsUnique :: UniqueIdM m => [(CoreVarName, CoreExpr)] -> CoreExpr -> m CoreExpr
- freeVars :: Char -> [String]
- getVar :: UniqueIdM m => m CoreVarName
- getVars :: UniqueIdM m => Int -> m [CoreVarName]
- duplicateExpr :: UniqueIdM m => CoreExpr -> m CoreExpr
- checkFreeVar :: CoreExpr -> CoreExpr -> Bool
- uniqueBoundVarsCore :: UniqueIdM m => Core -> m Core
- uniqueBoundVarsFunc :: UniqueIdM m => CoreFunc -> m CoreFunc
- uniqueBoundVars :: UniqueIdM m => CoreExpr -> m CoreExpr
Documentation
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
replaceFreeVarsUnique :: UniqueIdM m => [(CoreVarName, CoreExpr)] -> CoreExpr -> m CoreExprSource
getVar :: UniqueIdM m => m CoreVarNameSource
getVars :: UniqueIdM m => Int -> m [CoreVarName]Source
duplicateExpr :: UniqueIdM m => CoreExpr -> m CoreExprSource
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