Safe Haskell | None |
---|
Note: this module should NOT export externals. It is for common transformations needed by the other primitive modules.
- applyInContextT :: Translate c m a b -> a -> Translate c m a b
- callT :: TranslateH CoreExpr (CoreExpr, [CoreExpr])
- callPredT :: (Id -> [CoreExpr] -> Bool) -> TranslateH CoreExpr (CoreExpr, [CoreExpr])
- callNameT :: Name -> TranslateH CoreExpr (CoreExpr, [CoreExpr])
- callSaturatedT :: TranslateH CoreExpr (CoreExpr, [CoreExpr])
- callNameG :: Name -> TranslateH CoreExpr ()
- callDataConT :: TranslateH CoreExpr (DataCon, [Type], [CoreExpr])
- callDataConNameT :: Name -> TranslateH CoreExpr (DataCon, [Type], [CoreExpr])
- callsR :: Name -> RewriteH CoreExpr -> RewriteH Core
- callsT :: Name -> TranslateH CoreExpr b -> TranslateH Core [b]
- progIdsT :: TranslateH CoreProg [Id]
- consIdsT :: TranslateH CoreProg [Id]
- consRecIdsT :: TranslateH CoreProg [Id]
- consNonRecIdT :: TranslateH CoreProg Id
- bindVarsT :: TranslateH CoreBind [Var]
- nonRecVarT :: TranslateH CoreBind Var
- recIdsT :: TranslateH CoreBind [Id]
- defIdT :: TranslateH CoreDef Id
- lamVarT :: TranslateH CoreExpr Var
- letVarsT :: TranslateH CoreExpr [Var]
- letRecIdsT :: TranslateH CoreExpr [Id]
- letNonRecVarT :: TranslateH CoreExpr Var
- caseVarsT :: TranslateH CoreExpr [Var]
- caseWildIdT :: TranslateH CoreExpr Id
- caseAltVarsT :: TranslateH CoreExpr [[Var]]
- altVarsT :: TranslateH CoreAlt [Var]
- boundVarsT :: TranslateH a [Var]
- findBoundVarT :: Name -> TranslateH a Var
- findIdT :: Name -> TranslateH a Id
- findId :: Name -> HermitC -> HermitM Id
- wrongExprForm :: String -> String
- nodups :: Eq a => [a] -> Bool
- mapAlts :: (CoreExpr -> CoreExpr) -> [CoreAlt] -> [CoreAlt]
Utility Transformations
applyInContextT :: Translate c m a b -> a -> Translate c m a bSource
Apply a transformation to a value in the current context.
Finding function calls.
callNameT :: Name -> TranslateH CoreExpr (CoreExpr, [CoreExpr])Source
Succeeds if we are looking at an application of given function returning zero or more arguments to which it is applied.
callSaturatedT :: TranslateH CoreExpr (CoreExpr, [CoreExpr])Source
Succeeds if we are looking at a fully saturated function call.
callNameG :: Name -> TranslateH CoreExpr ()Source
Succeeds if we are looking at an application of given function
callDataConT :: TranslateH CoreExpr (DataCon, [Type], [CoreExpr])Source
Succeeds if we are looking at an application of a data constructor.
callDataConNameT :: Name -> TranslateH CoreExpr (DataCon, [Type], [CoreExpr])Source
Succeeds if we are looking at an application of a named data constructor.
callsR :: Name -> RewriteH CoreExpr -> RewriteH CoreSource
Apply a rewrite to all applications of a given function in a top-down manner, pruning on success.
callsT :: Name -> TranslateH CoreExpr b -> TranslateH Core [b]Source
Apply a translate to all applications of a given function in a top-down manner, pruning on success, collecting the results.
Collecting variables bound at a Node
progIdsT :: TranslateH CoreProg [Id]Source
List all identifiers bound at the top-level in a program.
consIdsT :: TranslateH CoreProg [Id]Source
List the identifiers bound by the top-level binding group at the head of the program.
consRecIdsT :: TranslateH CoreProg [Id]Source
List the identifiers bound by a recursive top-level binding group at the head of the program.
consNonRecIdT :: TranslateH CoreProg IdSource
Return the identifier bound by a non-recursive top-level binding at the head of the program.
bindVarsT :: TranslateH CoreBind [Var]Source
List all variables bound in a binding group.
nonRecVarT :: TranslateH CoreBind VarSource
Return the variable bound by a non-recursive let expression.
recIdsT :: TranslateH CoreBind [Id]Source
List all identifiers bound in a recursive binding group.
defIdT :: TranslateH CoreDef IdSource
Return the identifier bound by a recursive definition.
lamVarT :: TranslateH CoreExpr VarSource
Return the variable bound by a lambda expression.
letVarsT :: TranslateH CoreExpr [Var]Source
List the variables bound by a let expression.
letRecIdsT :: TranslateH CoreExpr [Id]Source
List the identifiers bound by a recursive let expression.
letNonRecVarT :: TranslateH CoreExpr VarSource
Return the variable bound by a non-recursive let expression.
caseVarsT :: TranslateH CoreExpr [Var]Source
List all variables bound by a case expression (in the alternatives and the wildcard binder).
caseWildIdT :: TranslateH CoreExpr IdSource
Return the case wildcard binder.
caseAltVarsT :: TranslateH CoreExpr [[Var]]Source
List the variables bound by all alternatives in a case expression.
altVarsT :: TranslateH CoreAlt [Var]Source
List the variables bound by a case alternative.
Finding variables bound in the Context
boundVarsT :: TranslateH a [Var]Source
Lifted version of boundVars
.
findBoundVarT :: Name -> TranslateH a VarSource
Find the unique variable bound in the context that matches the given name, failing if it is not unique.
findIdT :: Name -> TranslateH a IdSource
Lookup the name in the HermitC
first, then, failing that, in GHC's global reader environment.
Miscallaneous
wrongExprForm :: String -> StringSource
Constructs a common error message.
Argument String
should be the desired form of the expression.