- type AbsolutePathH = AbsolutePath Crumb
- type LocalPathH = LocalPath Crumb
- data HermitC
- initHermitC :: ModGuts -> HermitC
- data HermitBindingSite
- type BindingDepth = Int
- data HermitBinding
- hbDepth :: HermitBinding -> BindingDepth
- hbSite :: HermitBinding -> HermitBindingSite
- hbPath :: HermitBinding -> AbsolutePathH
- hermitBindingSiteExpr :: HermitBindingSite -> KureM CoreExpr
- hermitBindingSummary :: HermitBinding -> String
- hermitBindingExpr :: HermitBinding -> KureM CoreExpr
- class AddBindings c where
- addBindingGroup :: (AddBindings c, ReadPath c Crumb) => CoreBind -> c -> c
- addDefBinding :: (AddBindings c, ReadPath c Crumb) => Id -> c -> c
- addDefBindingsExcept :: (AddBindings c, ReadPath c Crumb) => Int -> [(Id, CoreExpr)] -> c -> c
- addLambdaBinding :: (AddBindings c, ReadPath c Crumb) => Var -> c -> c
- addAltBindings :: (AddBindings c, ReadPath c Crumb) => [Var] -> c -> c
- addCaseWildBinding :: (AddBindings c, ReadPath c Crumb) => (Id, CoreExpr, CoreAlt) -> c -> c
- addForallBinding :: (AddBindings c, ReadPath c Crumb) => 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 recursive binding that does not depend on the current expression (i.e. we're not in the binding group of that binding).
A recursive binding of a superexpression of the current node (i.e. we're in the RHS of that binding).
A recursive binding that is mutually recursive with the binding under consideration (i.e. we're in another definition in the same recursive binding group.).
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.