Copyright | (c) Kimiyuki Onaka 2021 |
---|---|
License | Apache License 2.0 |
Maintainer | kimiyuki95@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
\[ \newcommand\int{\mathbf{int}} \newcommand\bool{\mathbf{bool}} \newcommand\list{\mathbf{list}} \]
Synopsis
- run :: (MonadAlpha m, MonadError Error m) => Program -> m Program
- rule :: MonadAlpha m => RewriteRule m
- reduceBuild :: MonadAlpha m => RewriteRule m
- reduceMapBuild :: MonadAlpha m => RewriteRule m
- reduceMap :: Monad m => RewriteRule m
- reduceMapMap :: MonadAlpha m => RewriteRule m
- reduceFoldMap :: MonadAlpha m => RewriteRule m
- reduceFold :: Monad m => RewriteRule m
- reduceFoldBuild :: MonadAlpha m => RewriteRule m
Documentation
run :: (MonadAlpha m, MonadError Error m) => Program -> m Program Source #
run
does short cut fusion.
- This function is mainly for polymorphic reductions. This dosn't do much about concrete things, e.g., arithmetical operations.
- This doesn't do nothing about
Scanl
orSetAt
.
Example
Before:
length (map f (cons (-1) (range n)))
After:
n + 1
List of builtin functions which are reduced
Build functions
Nil
\(: \forall \alpha. \list(\alpha)\)Cons
\(: \forall \alpha. \alpha \to \list(\alpha) \to \list(\alpha)\)Range1
\(: \int \to \list(\int)\)Range2
\(: \int \to \int \to \list(\int)\)Range3
\(: \int \to \int \to \int \to \list(\int)\)
Map functions
Map
\(: \forall \alpha \beta. (\alpha \to \beta) \to \list(\alpha) \to \list(\beta)\)Filter
\(: \forall \alpha \beta. (\alpha \to \bool) \to \list(\alpha) \to \list(\beta)\)Reversed
\(: \forall \alpha. \list(\alpha) \to \list(\alpha)\)Sorted
\(: \forall \alpha. \list(\alpha) \to \list(\alpha)\)
Fold functions
internal rules
rule :: MonadAlpha m => RewriteRule m Source #
reduceBuild :: MonadAlpha m => RewriteRule m Source #
reduceMapBuild :: MonadAlpha m => RewriteRule m Source #
reduceMap :: Monad m => RewriteRule m Source #
reduceMapMap :: MonadAlpha m => RewriteRule m Source #
reduceFoldMap :: MonadAlpha m => RewriteRule m Source #
reduceFold :: Monad m => RewriteRule m Source #
reduceFoldBuild :: MonadAlpha m => RewriteRule m Source #