hermit-0.1.8.0: Haskell Equational Reasoning Model-to-Implementation Tunnel

Safe HaskellNone

Language.HERMIT.Primitive.Common

Contents

Description

Note: this module should NOT export externals. It is for common transformations needed by the other primitive modules.

Synopsis

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.

callT :: TranslateH CoreExpr (CoreExpr, [CoreExpr])Source

Lift GHC's collectArgs

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.

nodups :: Eq a => [a] -> BoolSource

Determine if a list contains no duplicated elements.