Copyright | (c) Kimiyuki Onaka 2021 |
---|---|

License | Apache License 2.0 |

Maintainer | kimiyuki95@gmail.com |

Stability | experimental |

Portability | portable |

Safe Haskell | None |

Language | Haskell2010 |

## Synopsis

- run :: (MonadAlpha m, MonadError Error m) => Program -> m Program
- rule :: (MonadAlpha m, MonadError Error m) => RewriteRule m

# Documentation

run :: (MonadAlpha m, MonadError Error m) => Program -> m Program Source #

`run`

removes unnecessary introductions and eliminations of tuples.
For example, this converts the following:

(fun xs -> (proj0 xs) + (proj1 xs)) (tuple 2 1)

to the follwoing:

(fun x0 x1 -> x0 + x1) 2 1

This can remove 1-tuples over higher-order functions. For example, this converts the following:

foldl (fun xs y -> tuple (proj0 xs + y) (tuple 0) [1, 2, 3]

to the follwoing:

tuple (foldl (fun x y -> x + y) 0 [1, 2, 3])

# internal rules

rule :: (MonadAlpha m, MonadError Error m) => RewriteRule m Source #