elm-syntax-0.3.2.0: Elm syntax and pretty-printing
Safe HaskellNone
LanguageHaskell2010

Language.Elm.Simplification

Synopsis

Documentation

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
  • { n = e, ... }.n = e