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 :: MonadError Error m => Program -> m Program
- rule :: MonadError Error m => RewriteRule m
- reduceConstArithmeticalExpr :: Monad m => RewriteRule m
- reduceConstMaxExpr :: Monad m => RewriteRule m
- reduceConstBooleanExpr :: Monad m => RewriteRule m
- reduceConstBitExpr :: Monad m => RewriteRule m
- reduceConstComparison :: Monad m => RewriteRule m
Documentation
run :: MonadError Error m => Program -> m Program Source #
run
folds constants in given programs.
For example, this converts the following:
3 x + 2 + 1
to the follwoing:
3 x + 3
internal rules
rule :: MonadError Error m => RewriteRule m Source #
reduceConstArithmeticalExpr :: Monad m => RewriteRule m Source #
List of functions which are reduced
Basic arithmetical functions
Negate
\(: \int \to \int\)Plus
\(: \int \to \int \to \int\)Minus
\(: \int \to \int \to \int\)Mult
\(: \int \to \int \to \int\)FloorDiv
\(: \int \to \int \to \int\)FloorMod
\(: \int \to \int \to \int\)CeilDiv
\(: \int \to \int \to \int\)CeilMod
\(: \int \to \int \to \int\)Pow
\(: \int \to \int \to \int\)
Advanced arithmetical functions
reduceConstMaxExpr :: Monad m => RewriteRule m Source #
reduceConstBooleanExpr :: Monad m => RewriteRule m Source #
reduceConstBitExpr :: Monad m => RewriteRule m Source #
List of functions which are reduced
Bitwise boolean functions
BitNot
\(: \int \to \int\)BitAnd
\(: \int \to \int \to \int\)BitOr
\(: \int \to \int \to \int\)BitXor
\(: \int \to \int \to \int\)BitLeftShift
\(: \int \to \int \to \int\)BitRightShift
\(: \int \to \int \to \int\)
reduceConstComparison :: Monad m => RewriteRule m Source #
List of functions which are reduced
Comparison functions
LessThan
\(: \forall \alpha. \alpha \to \alpha \to \bool\) (specialized to \(\alpha \in \lbrace \bool, \int \rbrace\))LessEqual
\(: \forall \alpha. \alpha \to \alpha \to \bool\) (specialized to \(\alpha \in \lbrace \bool, \int \rbrace\))GreaterThan
\(: \forall \alpha. \alpha \to \alpha \to \bool\) (specialized to \(\alpha \in \lbrace \bool, \int \rbrace\))GreaterEqual
\(: \forall \alpha. \alpha \to \alpha \to \bool\) (specialized to \(\alpha \in \lbrace \bool, \int \rbrace\))Equal
\(: \forall \alpha. \alpha \to \alpha \to \bool\) (specialized to \(\alpha \in \lbrace \bool, \int \rbrace\))NotEqual
\(: \forall \alpha. \alpha \to \alpha \to \bool\) (specialized to \(\alpha \in \lbrace \bool, \int \rbrace\))