[GHC] #14377: some results not expected with the addition
GHC
ghc-devs at haskell.org
Mon Oct 23 18:05:08 UTC 2017
#14377: some results not expected with the addition
-------------------------------------+-------------------------------------
Reporter: vanto | Owner: (none)
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.1
Resolution: invalid | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect result | Unknown/Multiple
at runtime | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Changes (by svenpanne):
* status: new => closed
* resolution: => invalid
Comment:
I fully understand that you want to change the standard way of `Show`ing
`Double`s, but this won't happen: There is an informal understanding that
`read` and `show` are a (weak) kind of inverses:
{{{
#!haskell
almostIdentity x = read (show x) `asTypeOf` x
}}}
There is no formal requirement in the Haskell Report for this, but you can
be sure that lots of code out there would break for no good reason if the
standard `Show` instance would simply lower the precision. Improving the
implementation so that it would output as few characters as possible while
retaining precision ''and'' performance would be another story, as has
already been pointed out. Again: If you want some special formatting, use
e.g.:
{{{
Prelude> Text.Printf.printf "%.5g\n" 12.3456789
12.34568
}}}
Just for the record: Try the equivalent of your examples in Chrome's
JavaScript console, in Firefox, Python 3.6's IDLE, in DrRacket's console
etc. etc., and you will see the same results as in GHC(i), and for a good
reason.
Another thing: A bug tracker is not really the right place to discuss wild
new ideas, IRC e.g. might be a better place to get some initial feedback
and perhaps learn why things are done they way they are.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14377#comment:13>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list