Safe Haskell | None |
---|
- externals :: [External]
- coreExprFreeIds :: CoreExpr -> [Id]
- coreExprFreeVars :: CoreExpr -> [Var]
- freeIdsT :: TranslateH CoreExpr [Id]
- freeVarsT :: TranslateH CoreExpr [Var]
- altFreeVarsT :: TranslateH CoreAlt [Var]
- altFreeVarsExclWildT :: TranslateH CoreAlt (Id -> [Var])
- substR :: Var -> CoreExpr -> RewriteH Core
- substExprR :: Var -> CoreExpr -> RewriteH CoreExpr
- letSubstR :: RewriteH CoreExpr
- safeLetSubstR :: RewriteH CoreExpr
- safeLetSubstPlusR :: RewriteH CoreExpr
- exprEqual :: CoreExpr -> CoreExpr -> Bool
- exprsEqual :: [CoreExpr] -> Bool
- coreEqual :: Core -> Core -> Maybe Bool
- inScope :: HermitC -> Id -> Bool
- showVars :: [Var] -> String
- rule :: String -> RewriteH CoreExpr
- rules :: [String] -> RewriteH CoreExpr
- lintExprT :: TranslateH CoreExpr String
- lintProgramT :: TranslateH CoreProg String
- lintModuleT :: TranslateH ModGuts String
- equivalent :: (a -> a -> Bool) -> [a] -> Bool
GHC-based Transformations
This module contains transformations that are reflections of GHC functions, or derived from GHC functions.
Externals that reflect GHC functions, or are derived from GHC functions.
Free Variables
coreExprFreeIds :: CoreExpr -> [Id]Source
List all free identifiers (value-level free variables) in the expression.
coreExprFreeVars :: CoreExpr -> [Var]Source
List all free variables (including types) in the expression.
freeIdsT :: TranslateH CoreExpr [Id]Source
Lifted version of coreExprFreeIds
.
freeVarsT :: TranslateH CoreExpr [Var]Source
Lifted version of coreExprFreeVars
.
altFreeVarsT :: TranslateH CoreAlt [Var]Source
The free variables in a case alternative, which excludes any identifiers bound in the alternative.
altFreeVarsExclWildT :: TranslateH CoreAlt (Id -> [Var])Source
A variant of altFreeVarsT
that returns a function that accepts the case wild-card binder before giving a result.
This is so we can use this with congruence combinators, for example:
caseT id (const altFreeVarsT) $ _ wild _ fvs -> [ f wild | f <- fvs ]
Substitution
substR :: Var -> CoreExpr -> RewriteH CoreSource
Substitute all occurrences of a variable with an expression, in either a program or an expression.
substExprR :: Var -> CoreExpr -> RewriteH CoreExprSource
Substitute all occurrences of a variable with an expression, in an expression.
safeLetSubstR :: RewriteH CoreExprSource
This is quite expensive (O(n) for the size of the sub-tree).
safeLetSubstPlusR :: RewriteH CoreExprSource
safeLetSubstPlusR
tries to inline a stack of bindings, stopping when reaches
the end of the stack of lets.
Equality
exprsEqual :: [CoreExpr] -> BoolSource
Utilities
rule :: String -> RewriteH CoreExprSource
Lookup a rule and attempt to construct a corresponding rewrite.
lintExprT :: TranslateH CoreExpr StringSource
Note: this can miss several things that a whole-module core lint will find. For instance, running this on the RHS of a binding, the type of the RHS will not be checked against the type of the binding. Running on the whole let expression will catch that however.
lintModuleT :: TranslateH ModGuts StringSource
Run the Core Lint typechecker. Fails on errors, with error messages. Succeeds returning warnings.
equivalent :: (a -> a -> Bool) -> [a] -> BoolSource