Copyright | (c) Kimiyuki Onaka 2021 |
---|---|
License | Apache License 2.0 |
Maintainer | kimiyuki95@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- newtype RewriteRule m = RewriteRule ([(VarName, Type)] -> Expr -> m (Maybe Expr))
- pureRewriteRule :: Monad m => ([(VarName, Type)] -> Expr -> Maybe Expr) -> RewriteRule m
- simpleRewriteRule :: Monad m => (Expr -> Maybe Expr) -> RewriteRule m
- applyRewriteRule :: MonadError Error m => RewriteRule m -> [(VarName, Type)] -> Expr -> StateT Integer m (Maybe Expr)
- applyRewriteRuleToplevelExpr :: MonadError Error m => RewriteRule m -> [(VarName, Type)] -> ToplevelExpr -> StateT Integer m (Maybe ToplevelExpr)
- applyRewriteRuleProgram :: MonadError Error m => RewriteRule m -> Program -> m (Maybe Program)
- applyRewriteRuleProgram' :: MonadError Error m => RewriteRule m -> Program -> m Program
- traceRewriteRule :: Monad m => RewriteRule m -> RewriteRule m
Documentation
newtype RewriteRule m Source #
Instances
Monad m => Semigroup (RewriteRule m) Source # | |
Defined in Jikka.Core.Language.RewriteRules (<>) :: RewriteRule m -> RewriteRule m -> RewriteRule m # sconcat :: NonEmpty (RewriteRule m) -> RewriteRule m # stimes :: Integral b => b -> RewriteRule m -> RewriteRule m # | |
Monad m => Monoid (RewriteRule m) Source # | |
Defined in Jikka.Core.Language.RewriteRules mempty :: RewriteRule m # mappend :: RewriteRule m -> RewriteRule m -> RewriteRule m # mconcat :: [RewriteRule m] -> RewriteRule m # |
pureRewriteRule :: Monad m => ([(VarName, Type)] -> Expr -> Maybe Expr) -> RewriteRule m Source #
simpleRewriteRule :: Monad m => (Expr -> Maybe Expr) -> RewriteRule m Source #
applyRewriteRule :: MonadError Error m => RewriteRule m -> [(VarName, Type)] -> Expr -> StateT Integer m (Maybe Expr) Source #
applyRewriteRule
applies a given rule to a given expr.
This rewrites on all sub-exprs of the given expr, and repeats to rewrite while it is possible.
- This function is idempotent.
- This function doesn't terminate when a given rewrite rule doesn't terminate.
applyRewriteRuleToplevelExpr :: MonadError Error m => RewriteRule m -> [(VarName, Type)] -> ToplevelExpr -> StateT Integer m (Maybe ToplevelExpr) Source #
applyRewriteRuleProgram :: MonadError Error m => RewriteRule m -> Program -> m (Maybe Program) Source #
applyRewriteRuleProgram' :: MonadError Error m => RewriteRule m -> Program -> m Program Source #
traceRewriteRule :: Monad m => RewriteRule m -> RewriteRule m Source #