Copyright | Copyright 2025 Yoo Chung |
---|---|
License | Apache-2.0 |
Maintainer | dev@chungyc.org |
Safe Haskell | None |
Language | GHC2021 |
Synopsis
- tidy :: Expression -> Expression
Documentation
tidy :: Expression -> Expression Source #
Tidies up expressions for nicer output.
Assumes that other simplifications have been applied first. In fact, it may undo changes that made other simplifications easier.
What is tidied up
This section shows examples of what this function tidies up.
>>>
toHaskell $ tidy $ "x" + negate "y"
"x - y"
>>>
toHaskell $ tidy $ "x" + Number (-2) * "y"
"x - 2 * y"
>>>
toHaskell $ tidy $ Number (-1) / Number 2
"negate (1 / 2)"
>>>
toHaskell $ tidy $ Number (-1) * "x"
"negate x"
>>>
toHaskell $ tidy $ (-"x") * "y"
"negate (x * y)"
>>>
toHaskell $ tidy $ "x" * (-"y")
"negate (x * y)"
>>>
toHaskell $ tidy $ (-"x") * (-"y")
"x * y"
>>>
toHaskell $ tidy $ "x" + ((-"y") + "z")
"x - y + z"