Proposal: Warn when using Enum instance of Float or Double

Simon Peyton-Jones simonpj at microsoft.com
Mon Jun 17 09:59:30 CEST 2013


I don't think it would be that hard to add DEPRECATE for instances.  A bit fiddly, and what should the syntax be.. but not really hard.  I can offer advice if someone wants to undertake it.


It's a cost/benefit question: how often will it be used?

Simon

| -----Original Message-----
| From: libraries-bounces at haskell.org [mailto:libraries-
| bounces at haskell.org] On Behalf Of Henning Thielemann
| Sent: 16 June 2013 10:12
| To: harry
| Cc: libraries at haskell.org
| Subject: Re: Proposal: Warn when using Enum instance of Float or Double
| 
| 
| 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
| 
| _______________________________________________
| Libraries mailing list
| Libraries at haskell.org
| http://www.haskell.org/mailman/listinfo/libraries



More information about the Libraries mailing list