| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Data.SigFig.PrettyPrint
Description
A module to unparse an expression.
Synopsis
- prettyPrint :: Expr -> Text
Documentation
prettyPrint :: Expr -> Text Source #
Pretty print an expression, adding parentheses where needed. Text emitted from the pretty printer is intended to be able to be re-parsed, into the same expression tree.
Examples
If you want to create expressions to pretty print, utilize the
functions in Types like below to make life easier.
>>>prettyPrint $ lMeasured 3 4.0"4.00"
>>>prettyPrint $ add [lConstant 3, lMeasured 2 3.5]"3c + 3.5"
>>>prettyPrint $ add [lConstant 3, mul [lMeasured 2 3.5, lConstant 2.7]]"3c + 3.5 * 2.7c"
>>>prettyPrint $ mul [lConstant 3, add [lMeasured 2 3.5, lConstant 2.7]]"3c * (3.5 + 2.7c)"