Jikka-5.0.11.1: A transpiler from Python to C++ for competitive programming
Copyright(c) Kimiyuki Onaka 2021
LicenseApache License 2.0
Maintainerkimiyuki95@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Jikka.Core.Convert.SpecializeFoldl

Description

\[ \newcommand\int{\mathbf{int}} \newcommand\bool{\mathbf{bool}} \newcommand\list{\mathbf{list}} \]

Synopsis

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\)