- type AbsolutePathH = AbsolutePath Crumb
- type LocalPathH = LocalPath Crumb
- data HermitC
- initHermitC :: ModGuts -> HermitC
- data HermitBindingSite
- type BindingDepth = Int
- type HermitBinding = (BindingDepth, HermitBindingSite)
- hermitBindingSiteExpr :: HermitBindingSite -> KureM CoreExpr
- hermitBindingExpr :: HermitBinding -> KureM CoreExpr
- class AddBindings c where
- addBindingGroup :: AddBindings c => CoreBind -> c -> c
- addDefBinding :: AddBindings c => Id -> c -> c
- addDefBindingsExcept :: AddBindings c => Int -> [(Id, CoreExpr)] -> 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 -> VarSet
- class BoundVars c => ReadBindings c where
- lookupHermitBinding :: (ReadBindings c, Monad m) => Var -> c -> m HermitBinding
- lookupHermitBindingDepth :: (ReadBindings c, Monad m) => Var -> c -> m BindingDepth
- lookupHermitBindingSite :: (ReadBindings c, Monad m) => Var -> BindingDepth -> c -> m HermitBindingSite
- class HasGlobalRdrEnv c where
- class HasCoreRules c where
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.
|ExtendPath HermitC Crumb|
|ReadPath HermitC Crumb|
|Extern [RewriteH Core]|
|Extern (BiRewriteH Core)|
|Extern (RewriteH CoreTC)|
|Extern (RewriteH Core)|
|Extern (TranslateH CoreTC String)|
|Extern (TranslateH CoreTC ())|
|Extern (TranslateH CoreTC LocalPathH)|
|Extern (TranslateH Core String)|
|Extern (TranslateH Core ())|
|Extern (TranslateH Core LocalPathH)|
HERMIT's representation of variable bindings. Bound expressions cannot be inlined without checking for shadowing issues (using the depth information).
A lambda-bound variable.
A non-recursive binding of an expression.
A (potentially) recursive binding of an expression.
A (potentially) recursive binding of a superexpression of the current node.
A variable bound in a case alternative.
|CASEWILD CoreExpr (AltCon, [Var])|
A case wildcard binder. We store both the scrutinised expression, and the case alternative
A universally quantified type variable.
The depth of a binding. Used, for example, to detect shadowing when inlining.
Retrieve the expression in a
HermitBindingSite, if there is one.
Retrieve the expression in a
HermitBinding, if there is one.
Adding bindings to contexts
A class of contexts that can have HERMIT bindings added to them.
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.
Add all bindings in a binding group to a context.
Add the binding for a recursive definition currently under examination. Note that because the expression may later be modified, the context only records the identifier, not the expression.
Add a list of recursive bindings to the context, except the nth binding in the list. The idea is to exclude the definition being descended into.
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.
Add the variables bound by a
DataCon in a case.
They are all bound at the same depth.
Add a wildcard binding for a specific case alternative.
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.
List all variables bound in the context that match the given name.
A class of contexts from which HERMIT bindings can be retrieved.
Lookup the binding for a variable in a context.
Lookup the depth of a variable's binding in a context.
Lookup the binding for a variable in a context, ensuring it was bound at the specified depth.
Accessing the Global Reader Environment from the context
A class of contexts that store the Global Reader Environment.