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

Safe HaskellNone

HERMIT.Dictionary.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 x bSource

Apply a transformation to a value in the current context.

Finding function calls.

callT :: Monad m => Translate c m CoreExpr (CoreExpr, [CoreExpr])Source

Lift GHC's collectArgs

callNameT :: MonadCatch m => Name -> Translate c m 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 :: Monad m => Translate c m CoreExpr (CoreExpr, [CoreExpr])Source

Succeeds if we are looking at a fully saturated function call.

callNameG :: MonadCatch m => Name -> Translate c m CoreExpr ()Source

Succeeds if we are looking at an application of given function

callDataConT :: MonadCatch m => Translate c m CoreExpr (DataCon, [Type], [CoreExpr])Source

Succeeds if we are looking at an application of a data constructor.

callDataConNameT :: MonadCatch m => Name -> Translate c m CoreExpr (DataCon, [Type], [CoreExpr])Source

Succeeds if we are looking at an application of a named data constructor.

callsR :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, MonadCatch m) => Name -> Rewrite c m CoreExpr -> Rewrite c m CoreSource

Apply a rewrite to all applications of a given function in a top-down manner, pruning on success.

callsT :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, MonadCatch m) => Name -> Translate c m CoreExpr b -> Translate c m 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 variable bindings

progConsIdsT :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, MonadCatch m) => Translate c m CoreProg [Id]Source

List the identifiers bound by the top-level binding group at the head of the program.

progConsRecIdsT :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, Monad m) => Translate c m CoreProg [Id]Source

List the identifiers bound by a recursive top-level binding group at the head of the program.

progConsNonRecIdT :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, Monad m) => Translate c m CoreProg IdSource

Return the identifier bound by a non-recursive top-level binding at the head of the program.

nonRecVarT :: (ExtendPath c Crumb, Monad m) => Translate c m CoreBind VarSource

Return the variable bound by a non-recursive let expression.

recIdsT :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, Monad m) => Translate c m CoreBind [Id]Source

List all identifiers bound in a recursive binding group.

lamVarT :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr VarSource

Return the variable bound by a lambda expression.

letVarsT :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, MonadCatch m) => Translate c m CoreExpr [Var]Source

List the variables bound by a let expression.

letRecIdsT :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr [Id]Source

List the identifiers bound by a recursive let expression.

letNonRecVarT :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr VarSource

Return the variable bound by a non-recursive let expression.

caseVarsT :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr [Var]Source

List all variables bound by a case expression (in the alternatives and the wildcard binder).

caseWildIdT :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr IdSource

Return the case wildcard binder.

caseAltVarsT :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr [[Var]]Source

List the variables bound by all alternatives in a case expression.

Finding variables bound in the Context

boundVarsT :: (BoundVars c, Monad m) => Translate c m a VarSetSource

Lifted version of boundVars.

findBoundVarT :: (BoundVars c, MonadCatch m) => Name -> Translate c m a VarSource

Find the unique variable bound in the context that matches the given name, failing if it is not unique.

findIdT :: (BoundVars c, HasGlobalRdrEnv c, HasDynFlags m, MonadThings m, MonadCatch m) => Name -> Translate c m a IdSource

Lookup the name in the context first, then, failing that, in GHC's global reader environment.

varBindingDepthT :: (ReadBindings c, Monad m) => Var -> Translate c m g BindingDepthSource

Find the depth of a variable's binding.

varIsOccurrenceOfT :: (ExtendPath c Crumb, ReadBindings c, Monad m) => Var -> BindingDepth -> Translate c m Var BoolSource

Determine if the current variable matches the given variable, and is bound at the specified depth (helpful to detect shadowing).

exprIsOccurrenceOfT :: (ExtendPath c Crumb, ReadBindings c, Monad m) => Var -> BindingDepth -> Translate c m CoreExpr BoolSource

Determine if the current expression is an occurrence of the given variable, bound at the specified depth (helpful to detect shadowing).

wrongExprForm :: String -> StringSource

Constructs a common error message. Argument String should be the desired form of the expression.