Proposal: Warn when using Enum instance of Float or Double

Henning Thielemann lemming at henning-thielemann.de
Sun Jun 16 11:12:07 CEST 2013


On Sun, 16 Jun 2013, harry wrote:

> 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.
>
> I would therefore like to propose that the usage of an Enum instance of
> Float or Double generate a compiler warning, such as "The Enum instance of
> Float is subject to rounding errors". Deadline: 2 weeks.

I would also like to see these instances be removed or deprecated. 
Unfortunately, GHC currently does not allow to DEPRECATE an instance. With 
this feature one might also tag intentionally omitted instances, like Num 
instance for (or 'of' :-) functions:
    http://hackage.haskell.org/trac/ghc/ticket/7775



More information about the Libraries mailing list