Copyright | Copyright 2025 Yoo Chung |
---|---|
License | Apache-2.0 |
Maintainer | dev@chungyc.org |
Safe Haskell | None |
Language | GHC2021 |
Synopsis
- simplify :: Expression -> Expression
Documentation
simplify :: Expression -> Expression Source #
Cancel out common numeric factors in fractions.
>>>
toHaskell $ simplify $ 10 / 20
"1 / 2"
>>>
toHaskell $ simplify $ Number (-15) / Number (-10)
"3 / 2"
>>>
toHaskell $ simplify $ (12 * "x") / (4 * "y")
"(3 * x) / (1 * y)"
> toHaskell $ simplify $ (15 * "x" + 20 * "y") / (5 * "z" - 35 * "u")
"(3 * x + 4 * y) / (1 * z - 7 * u)"
Assumes numeric folding and algebraic ring ordering has been applied.