[Haskell-cafe] instance Enum Double considered not entirely great?

Chris Smith cdsmith at gmail.com
Tue Sep 20 21:48:14 CEST 2011


On Tue, 2011-09-20 at 15:28 -0400, Casey McCann wrote:
> I actually think the brokenness of Ord for floating point values is
> worse in many ways, as demonstrated by the ability to insert a value
> into a Data.Set.Set and have other values "disappear" from the set as
> a result.

Definitely Ord is worse.  I'd very much like to see the Ord instance for
Float and Double abandon the IEEE semantics and just put "NaN" somewhere
in there -- doesn't matter where -- and provide new functions for the
IEEE semantics.

As for Enum, if someone were to want a type class to represent an
enumeration of all the values of a type, then such a thing is reasonable
to want.  Maybe you can even reasonably wish it were called Enum.  But
it would be the *wrong* thing to use as a desugaring for list range
notation.  List ranges are very unlikely to be useful or even meaningful
for most such enumerations (what is [ Red, Green .. LightPurple]?); and
conversely, as we've seen in this thread, list ranges *are* useful in
situations where they are not a suitable way of enumerating all values
of a type.

-- 
Chris




More information about the Haskell-Cafe mailing list