Safe Haskell | None |
---|
- data HermitC
- initHermitC :: ModGuts -> HermitC
- data HermitBindingSite
- type BindingDepth = Int
- type HermitBinding = (BindingDepth, HermitBindingSite)
- hermitBindingSiteExpr :: HermitBindingSite -> Maybe CoreExpr
- hermitBindingExpr :: HermitBinding -> Maybe CoreExpr
- class AddBindings c where
- addHermitBindings :: [(Var, HermitBindingSite)] -> c -> c
- addBindingGroup :: AddBindings c => CoreBind -> c -> c
- addLambdaBinding :: AddBindings c => Var -> c -> c
- addAltBindings :: AddBindings c => [Var] -> c -> c
- addCaseWildBinding :: AddBindings c => (Id, CoreExpr, CoreAlt) -> c -> c
- addForallBinding :: AddBindings c => TyVar -> c -> c
- class BoundVars c where
- boundIn :: ReadBindings c => Var -> c -> Bool
- findBoundVars :: BoundVars c => Name -> c -> [Var]
- class BoundVars c => ReadBindings c where
- hermitDepth :: c -> BindingDepth
- hermitBindings :: c -> Map Var HermitBinding
- lookupHermitBinding :: ReadBindings c => Var -> c -> Maybe HermitBinding
- class HasGlobalRdrEnv c where
- hermitGlobalRdrEnv :: c -> GlobalRdrEnv
- class HasCoreRules c where
- hermitCoreRules :: c -> [CoreRule]
HERMIT Contexts
The Standard Context
The HERMIT context, containing all bindings in scope and the current location in the AST. The bindings here are lazy by choice, so that we can avoid the cost of building the context if we never use it.
HasGlobalRdrEnv HermitC | |
HasCoreRules HermitC | |
ReadBindings HermitC | |
BoundVars HermitC | |
AddBindings HermitC | |
ExtendPath HermitC Crumb | Extend the |
ReadPath HermitC Crumb | Retrieve the |
Extern (BiRewriteH Core) | |
Extern (RewriteH CoreTC) | |
Extern (RewriteH Core) | |
Extern (TranslateH CoreTC String) | |
Extern (TranslateH Core String) | |
Extern (TranslateH Core ()) | |
Extern (TranslateH Core PathH) |
Bindings
data HermitBindingSite Source
HERMIT's representation of variable bindings. Bound expressions cannot be inlined without checking for shadowing issues (using the depth information).
type BindingDepth = IntSource
The depth of a binding. Used, for example, to detect shadowing when inlining.
type HermitBinding = (BindingDepth, HermitBindingSite)Source
hermitBindingSiteExpr :: HermitBindingSite -> Maybe CoreExprSource
Retrieve the expression in a HermitBindingSite
, if there is one.
hermitBindingExpr :: HermitBinding -> Maybe CoreExprSource
Retrieve the expression in a HermitBinding
, if there is one.
Adding bindings to contexts
class AddBindings c whereSource
A class of contexts that can have HERMIT bindings added to them.
addHermitBindings :: [(Var, HermitBindingSite)] -> c -> cSource
Add a complete set of parrallel bindings to the context. (Parallel bindings occur in recursive let bindings and case alternatives.) This can also be used for solitary bindings (e.g. lambdas). Bindings are added in parallel sets to help with shadowing issues.
AddBindings HermitC | |
AddBindings PrettyC | |
AddBindings (SnocPath crumb) | Here the bindings are just discarded. |
addBindingGroup :: AddBindings c => CoreBind -> c -> cSource
Add all bindings in a binding group to a context.
addLambdaBinding :: AddBindings c => Var -> c -> cSource
Add a lambda bound variable to a context. All that is known is the variable, which may shadow something. If so, we don't worry about that here, it is instead checked during inlining.
addAltBindings :: AddBindings c => [Var] -> c -> cSource
Add the variables bound by a DataCon
in a case.
They are all bound at the same depth.
addCaseWildBinding :: AddBindings c => (Id, CoreExpr, CoreAlt) -> c -> cSource
Add a wildcard binding for a specific case alternative.
addForallBinding :: AddBindings c => TyVar -> c -> cSource
Add a universally quantified type variable to a context.
Reading bindings from the context
A class of contexts that stores the set of variables in scope that have been bound during the traversal.
boundIn :: ReadBindings c => Var -> c -> BoolSource
Determine if a variable is bound in a context.
findBoundVars :: BoundVars c => Name -> c -> [Var]Source
List all variables bound in the context that match the given name.
class BoundVars c => ReadBindings c whereSource
A class of contexts from which HERMIT bindings can be retrieved.
hermitDepth :: c -> BindingDepthSource
hermitBindings :: c -> Map Var HermitBindingSource
lookupHermitBinding :: ReadBindings c => Var -> c -> Maybe HermitBindingSource
Lookup the binding for a variable in a context.
Accessing the Global Reader Environment from the context
class HasGlobalRdrEnv c whereSource
A class of contexts that store the Global Reader Environment.
hermitGlobalRdrEnv :: c -> GlobalRdrEnvSource
Accessing GHC rewrite rules from the context
class HasCoreRules c whereSource
A class of contexts that store GHC rewrite rules.
hermitCoreRules :: c -> [CoreRule]Source