| Copyright | (c) Kimiyuki Onaka 2021 |
|---|---|
| License | Apache License 2.0 |
| Maintainer | kimiyuki95@gmail.com |
| Stability | experimental |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Jikka.Core.Convert.SpecializeFoldl
Description
\[ \newcommand\int{\mathbf{int}} \newcommand\bool{\mathbf{bool}} \newcommand\list{\mathbf{list}} \]
Synopsis
- run :: (MonadAlpha m, MonadError Error m) => Program -> m Program
Documentation
run :: (MonadAlpha m, MonadError Error m) => Program -> m Program Source #
run reduces summations and products.
Example
Before:
foldl (fun x y -> x + y) 0 xs
After:
sum xs
List of builtin functions which are reduced
Source functions
Foldl\(: \forall \alpha \beta. (\beta \to \alpha \to \beta) \to \beta \to \list(\alpha) \to \beta\)
Destination functions
Sum\(: \list(\int) \to \int\)Product\(: \list(\int) \to \int\)ModSum\(: \list(\int) \to \int \to \int\)ModProduct\(: \list(\int) \to \int \to \int\)All\(: \list(\bool) \to \bool\)Any\(: \list(\bool) \to \bool\)Max1\(: \forall \alpha. \list(\alpha) \to \alpha\)Min1\(: \forall \alpha. \list(\alpha) \to \alpha\)Iterate\(: \forall \alpha. \int \to (\alpha \to \alpha) \to \alpha \to \alpha\)