Copyright | (c) Justus Sagemüller 2017 |
---|---|
License | GPL v3 |
Maintainer | (@) jsagemue $ uni-koeln.de |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Documentation
A drop-in replacement for Show
. The behaviour is mostly the same:
the result of show
should be valid Haskell code, and read
ing back such a
value should give the original value – but, unlike in Show
, we don't
require this in an exact sense, i.e.
is not necessarily
fulfilled.read
(show
x) == x
Notably for floating-point values, we allow a slight deviation if
it considerably shortens the shown representation: for example,
0.90000004 :: Float
, which can easily come up as
the result of a computation which should in principle be exactly 0.9
, is shown
as 0.9
instead. We do however not commit to any particular fixed precision;
it depends on the type and the order of magnitude which amount of rounding is
appropriate. See the test suite for some examples.
ltdPrecShowsPrec :: RealFloat n => Int -> Int -> n -> ShowS Source
displays floating-point values with a precision
of at least ltdPrecShowsPrec
prcnprcn
digits. That does not mean it will necessarily display
that many digits, rather it tries to always choose the shortest representation
with the required precision.