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 x b
- callT :: Monad m => Translate c m CoreExpr (CoreExpr, [CoreExpr])
- callPredT :: Monad m => (Id -> [CoreExpr] -> Bool) -> Translate c m CoreExpr (CoreExpr, [CoreExpr])
- callNameT :: MonadCatch m => Name -> Translate c m CoreExpr (CoreExpr, [CoreExpr])
- callSaturatedT :: Monad m => Translate c m CoreExpr (CoreExpr, [CoreExpr])
- callNameG :: MonadCatch m => Name -> Translate c m CoreExpr ()
- callDataConT :: MonadCatch m => Translate c m CoreExpr (DataCon, [Type], [CoreExpr])
- callDataConNameT :: MonadCatch m => Name -> Translate c m CoreExpr (DataCon, [Type], [CoreExpr])
- callsR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Name -> Rewrite c m CoreExpr -> Rewrite c m Core
- callsT :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Name -> Translate c m CoreExpr b -> Translate c m Core [b]
- progIdsT :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Translate c m CoreProg [Id]
- consIdsT :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Translate c m CoreProg [Id]
- consRecIdsT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreProg [Id]
- consNonRecIdT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreProg Id
- bindVarsT :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Translate c m CoreBind [Var]
- nonRecVarT :: (ExtendPath c Crumb, Monad m) => Translate c m CoreBind Var
- recIdsT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreBind [Id]
- defIdT :: (ExtendPath c Crumb, Monad m) => Translate c m CoreDef Id
- lamVarT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr Var
- letVarsT :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Translate c m CoreExpr [Var]
- letRecIdsT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr [Id]
- letNonRecVarT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr Var
- caseVarsT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr [Var]
- caseWildIdT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr Id
- caseAltVarsT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr [[Var]]
- altVarsT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreAlt [Var]
- boundVarsT :: (BoundVars c, Monad m) => Translate c m a (Set Var)
- findBoundVarT :: (BoundVars c, MonadCatch m) => Name -> Translate c m a Var
- findIdT :: (BoundVars c, HasGlobalRdrEnv c, HasDynFlags m, MonadThings m, MonadCatch m) => Name -> Translate c m a Id
- findId :: (BoundVars c, HasGlobalRdrEnv c, HasDynFlags m, MonadThings m) => Name -> c -> m 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 x bSource
Apply a transformation to a value in the current context.
Finding function calls.
callPredT :: Monad m => (Id -> [CoreExpr] -> Bool) -> Translate c m CoreExpr (CoreExpr, [CoreExpr])Source
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, 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, 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 variables bound at a Node
progIdsT :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Translate c m CoreProg [Id]Source
List all identifiers bound at the top-level in a program.
consIdsT :: (ExtendPath 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.
consRecIdsT :: (ExtendPath 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.
consNonRecIdT :: (ExtendPath 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.
bindVarsT :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Translate c m CoreBind [Var]Source
List all variables bound in a binding group.
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, AddBindings c, Monad m) => Translate c m CoreBind [Id]Source
List all identifiers bound in a recursive binding group.
defIdT :: (ExtendPath c Crumb, Monad m) => Translate c m CoreDef IdSource
Return the identifier bound by a recursive definition.
lamVarT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr VarSource
Return the variable bound by a lambda expression.
letVarsT :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Translate c m CoreExpr [Var]Source
List the variables bound by a let expression.
letRecIdsT :: (ExtendPath 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, AddBindings c, Monad m) => Translate c m CoreExpr VarSource
Return the variable bound by a non-recursive let expression.
caseVarsT :: (ExtendPath 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, AddBindings c, Monad m) => Translate c m CoreExpr IdSource
Return the case wildcard binder.
caseAltVarsT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreExpr [[Var]]Source
List the variables bound by all alternatives in a case expression.
altVarsT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreAlt [Var]Source
List the variables bound by a case alternative.
Finding variables bound in the Context
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.
findId :: (BoundVars c, HasGlobalRdrEnv c, HasDynFlags m, MonadThings m) => Name -> c -> m IdSource
Miscallaneous
wrongExprForm :: String -> StringSource
Constructs a common error message.
Argument String
should be the desired form of the expression.