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, MonadError Error m) => RewriteRule m
- reduceConstArithmeticExpr :: (MonadAlpha m, MonadError Error m) => RewriteRule m
- reduceConstMaxExpr :: (MonadAlpha m, MonadError Error m) => RewriteRule m
- reduceIdempotentBooleanExpr :: (MonadAlpha m, MonadError Error m) => RewriteRule m
- reduceUnitBooleanExpr :: (MonadAlpha m, MonadError Error m) => RewriteRule m
- reduceConstBooleanExpr :: (MonadAlpha m, MonadError Error m) => RewriteRule m
- reduceUnitBitExpr :: (MonadAlpha m, MonadError Error m) => RewriteRule m
- reduceConstBitExpr :: (MonadAlpha m, MonadError Error m) => RewriteRule m
- reduceConstIntComparison :: (MonadAlpha m, MonadError Error m) => RewriteRule m
- reduceUnitBooleanComparison :: (MonadAlpha m, MonadError Error m) => RewriteRule m
Documentation
run :: (MonadAlpha m, 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 :: (MonadAlpha m, MonadError Error m) => RewriteRule m Source #
reduceConstArithmeticExpr :: (MonadAlpha m, MonadError Error 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 :: (MonadAlpha m, MonadError Error m) => RewriteRule m Source #
reduceIdempotentBooleanExpr :: (MonadAlpha m, MonadError Error m) => RewriteRule m Source #
reduceUnitBooleanExpr :: (MonadAlpha m, MonadError Error m) => RewriteRule m Source #
reduceConstBooleanExpr :: (MonadAlpha m, MonadError Error m) => RewriteRule m Source #
List of functions which are reduced
Boolean functions
If
\(: \forall \alpha. \bool \to \alpha \to \alpha \to \alpha\)
reduceUnitBitExpr :: (MonadAlpha m, MonadError Error 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\)
reduceConstBitExpr :: (MonadAlpha m, MonadError Error 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\)
reduceConstIntComparison :: (MonadAlpha m, MonadError Error 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\))
reduceUnitBooleanComparison :: (MonadAlpha m, MonadError Error 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\))