Skip to content

Warn when using Enum instance for Float or Double

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 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.

Trac metadata
Trac field Value
Version 7.6.3
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information