Safe Haskell | None |
---|
- externals :: [External]
- anyCallR :: forall c m. (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m Core -> Rewrite c m Core
- coreExprFreeIds :: CoreExpr -> Set Id
- coreExprFreeVars :: CoreExpr -> Set Var
- typeFreeVars :: Type -> Set Var
- freeIdsT :: Monad m => Translate c m CoreExpr (Set Id)
- freeVarsT :: Monad m => Translate c m CoreExpr (Set Var)
- freeTyVarsT :: Monad m => Translate c m Type (Set Var)
- altFreeVarsT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreAlt (Set Var)
- altFreeVarsExclWildT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreAlt (Id -> Set Var)
- substR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Var -> CoreExpr -> Rewrite c m Core
- substExprR :: Monad m => Var -> CoreExpr -> Rewrite c m CoreExpr
- letSubstR :: MonadCatch m => Rewrite c m CoreExpr
- safeLetSubstR :: (ReadBindings c, MonadCatch m) => Rewrite c m CoreExpr
- safeLetSubstPlusR :: (ExtendPath c Crumb, AddBindings c, ReadBindings c, MonadCatch m) => Rewrite c m CoreExpr
- exprEqual :: CoreExpr -> CoreExpr -> Bool
- exprsEqual :: [CoreExpr] -> Bool
- coreEqual :: Core -> Core -> Maybe Bool
- inScope :: ReadBindings c => c -> Id -> Bool
- showVars :: [Var] -> String
- rule :: (ReadBindings c, HasCoreRules c) => String -> Rewrite c HermitM CoreExpr
- rules :: (ReadBindings c, HasCoreRules c) => [String] -> Rewrite c HermitM CoreExpr
- equivalent :: (a -> a -> Bool) -> [a] -> Bool
- lintExprT :: (BoundVars c, Monad m, HasDynFlags m) => Translate c m CoreExpr String
- lintProgramT :: TranslateH CoreProg String
- lintModuleT :: TranslateH ModGuts String
- specConstrR :: RewriteH ModGuts
GHC-based Transformations
This module contains transformations that are reflections of GHC functions, or derived from GHC functions.
Externals that reflect GHC functions, or are derived from GHC functions.
anyCallR :: forall c m. (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m Core -> Rewrite c m CoreSource
Top-down traversal tuned to matching function calls.
Free Variables
coreExprFreeIds :: CoreExpr -> Set IdSource
List all free identifiers (value-level free variables) in the expression.
coreExprFreeVars :: CoreExpr -> Set VarSource
List all free variables (including types) in the expression.
typeFreeVars :: Type -> Set VarSource
List all free variables in a type.
freeTyVarsT :: Monad m => Translate c m Type (Set Var)Source
Lifted version of typeFreeVars
.
altFreeVarsT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreAlt (Set Var)Source
The free variables in a case alternative, which excludes any identifiers bound in the alternative.
altFreeVarsExclWildT :: (ExtendPath c Crumb, AddBindings c, Monad m) => Translate c m CoreAlt (Id -> Set Var)Source
A variant of altFreeVarsT
that returns a function that accepts the case wild-card binder before giving a result.
This is so we can use this with congruence combinators, for example:
caseT id (const altFreeVarsT) $ _ wild _ fvs -> [ f wild | f <- fvs ]
Substitution
substR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Var -> CoreExpr -> Rewrite c m CoreSource
Substitute all occurrences of a variable with an expression, in either a program or an expression.
substExprR :: Monad m => Var -> CoreExpr -> Rewrite c m CoreExprSource
Substitute all occurrences of a variable with an expression, in an expression.
letSubstR :: MonadCatch m => Rewrite c m CoreExprSource
(let x = e1 in e2) ==> (e2[e1/x]), x must not be free in e1.
safeLetSubstR :: (ReadBindings c, MonadCatch m) => Rewrite c m CoreExprSource
This is quite expensive (O(n) for the size of the sub-tree).
safeLetSubstPlusR :: (ExtendPath c Crumb, AddBindings c, ReadBindings c, MonadCatch m) => Rewrite c m CoreExprSource
safeLetSubstPlusR
tries to inline a stack of bindings, stopping when reaches
the end of the stack of lets.
Equality
exprsEqual :: [CoreExpr] -> BoolSource
Utilities
inScope :: ReadBindings c => c -> Id -> BoolSource
Determine whether an identifier is in scope.
rule :: (ReadBindings c, HasCoreRules c) => String -> Rewrite c HermitM CoreExprSource
Lookup a rule and attempt to construct a corresponding rewrite.
rules :: (ReadBindings c, HasCoreRules c) => [String] -> Rewrite c HermitM CoreExprSource
equivalent :: (a -> a -> Bool) -> [a] -> BoolSource
Lifted GHC capabilities
lintExprT :: (BoundVars c, Monad m, HasDynFlags m) => Translate c m CoreExpr StringSource
Note: this can miss several things that a whole-module core lint will find. For instance, running this on the RHS of a binding, the type of the RHS will not be checked against the type of the binding. Running on the whole let expression will catch that however.
lintModuleT :: TranslateH ModGuts StringSource
Run the Core Lint typechecker. Fails on errors, with error messages. Succeeds returning warnings.