
#15509: `showEFloat` inconsistency introduced in base-4.12 -------------------------------------+------------------------------------- Reporter: hvr | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.6.1-beta1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by hvr: Old description:
While base-4.11 had a `showEFloat` that behaved like
{{{#!hs showEFloat (Just n) | n <= 0 == showEFloat (Just 1) }}}
For non-positive values, base-4.12 introduced an unfortunate inconsistency:
{{{#!hs showEFloat (Just n) | n < 0 == showEFloat (Just 1) -- NB: *not* equivalent to showEFloat (Just 0) }}}
e.g. now we have
{{{#!hs showEFloat (Just 2) 1.0 "" == "1.00e0" showEFloat (Just 1) 1.0 "" == "1.0e0" showEFloat (Just 0) 1.0 "" == "1e0" showEFloat (Just (-1)) 1.0 "" == "1.0e0" showEFloat (Just (-2)) 1.0 "" == "1.0e0" }}}
iow, negative `n`s in the precision argument are now treated differently from `(Just 0)` which is a source of subtle bugs for API consumers which assume `showEFloat` to have "continuous total" semantics for the precision argument.
New description: While base-4.11 had a `showEFloat` that behaved like {{{#!hs showEFloat (Just n) | n <= 0 == showEFloat (Just 1) }}} For non-positive values, base-4.12 introduced an unfortunate inconsistency: {{{#!hs showEFloat (Just n) | n < 0 == showEFloat (Just 1) -- NB: *not* equivalent to showEFloat (Just 0) }}} e.g. now we have {{{#!hs showEFloat (Just 2) 1.0 "" == "1.00e0" showEFloat (Just 1) 1.0 "" == "1.0e0" showEFloat (Just 0) 1.0 "" == "1e0" showEFloat (Just (-1)) 1.0 "" == "1.0e0" showEFloat (Just (-2)) 1.0 "" == "1.0e0" }}} iow, negative `n`s in the precision argument are now treated differently from `(Just 0)` which is a source of subtle bugs for API consumers which assume `showEFloat` to have "continuous total" (or rather, saturated subtraction) semantics for the precision argument. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15509#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler