Safe Haskell | None |
---|---|

Language | Haskell2010 |

## Synopsis

- simplifyDefinition :: Definition -> Definition
- simplifyExpression :: Expression v -> Expression v

# Documentation

simplifyDefinition :: Definition -> Definition Source #

Perform `simplifyExpression`

on all `Expression`

s inside the given
`Definition`

.

simplifyExpression :: Expression v -> Expression v Source #

Run the following simplifications on the given expression:

identity x = x

(f >> g) x = g (f x)

f >> identity = f

identity >> f = f

(f << g) x = f (g x)

f << identity = f

identity << f= f

identity <| x = x

x |> identity = x

x :: [y, z, ...] = [x, y, z, ...]

- Calls to
`String.join`

,`String.concat`

,`List.concat`

, and`++`

with known arguments are simplified. For example,`String.join "`

*" [Config.api, "endpoint"] = Config.api ++ "*endpoint" (x. e x) = e

- Inline
`x`

in`e'`

in`let x = e in e'`

if either: `e`

is freely duplicable, e.g. it's just a variable or a numeric literal.`x`

occurs zero or one times in`e'`

.`case e of ... prefixBranches pat -> branch ...`

is simplified to`let xs = es in branch`

provided that`e`

matches none of`prefixBranches`

and that it matches`pat`

.- case-of-case