[GHC] #8012: Warn when using Enum instance for Float or Double
GHC
ghc-devs at haskell.org
Tue Jun 25 08:43:25 CEST 2013
#8012: Warn when using Enum instance for Float or Double
-----------------------------+----------------------------------------------
Reporter: gidyn | Owner:
Type: feature request | Status: new
Priority: normal | Component: Compiler
Version: 7.6.3 | Keywords:
Os: Unknown/Multiple | Architecture: Unknown/Multiple
Failure: None/Unknown | Blockedby:
Blocking: | Related:
-----------------------------+----------------------------------------------
The Enum instances for Float and Double have dubious semantics which cause
endless confusion, e.g.
[http://stackoverflow.com/questions/13203471/the-math-
behind-1-0999999999999999-in-haskell],
[http://stackoverflow.com/questions/9810002/floating-point-list-
generator],
[http://stackoverflow.com/questions/7290438/haskell-ranges-and-floats],
[http://stackoverflow.com/questions/10328435/how-to-solve-floating-point-
number-getting-wrong-in-list-haskell],
and many more.
It is therefore proposed that the usage of an Enum instance for Float or
Double generate a compiler warning, such as "The Enum instance for Float
is subject to rounding errors".
A discussion of this on [http://haskell.1045720.n5.nabble.com/Proposal-
Warn-when-using-Enum-instance-of-Float-or-Double-td5731620.html the
libraries list] suggested that such a warning would be desired, although
the discussion mostly focused on whether the libraries list is an
appropriate place for this discussion.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/8012>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list