Copyright | (c) Justus Sagemüller 2017 |
---|---|
License | GPL v3 |
Maintainer | (@) jsagemue $ uni-koeln.de |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
- class Show a where
- print :: Show a => a -> IO ()
- ltdPrecShowsPrec :: RealFloat n => Int -> Int -> n -> ShowS
- showsPrecWithSharedPrecision :: (ShowMagnitudeRangeLimited n, RealFloat sn, Traversable list) => (n -> sn) -> Int -> Int -> list n -> list ShowS
- class Show a => ShowMagnitudeRangeLimited a where
Replacement for the standard class
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.
Utility (unstable)
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.
showsPrecWithSharedPrecision Source #
:: (ShowMagnitudeRangeLimited n, RealFloat sn, Traversable list) | |
=> (n -> sn) | Magnitude-function. Should be a norm. |
-> Int | Precision of the type, in significant decimals. This will be used to trim the length of all entries to match the expected numerical uncertainty of the biggest one. |
-> Int | Precedence of the enclosing context in which the values are to be shown. |
-> list n | Values to show |
-> list ShowS | Individual values' string representation. |
class Show a => ShowMagnitudeRangeLimited a where Source #