[Haskell-cafe] instance Enum Double considered not entirely great?
Ketil Malde
ketil at malde.org
Tue Sep 20 17:39:49 CEST 2011
Chris Smith <cdsmith at gmail.com> writes:
> It would be a shame if we lost an occasionally useful and easy to read
You forgot "confusing"? Expecting Enum to enumerate all inhabitants of
a type seems very reasonable to me, and seems to hold for all
non-floating point types. A numeric range [a..a+n] might be expected
to have a+n+1 elements, but that doesn't hold either for Float and
Double. I think Enum for floating point values is broken - but it is
reality, so we need to deal with it.
> Instead, perhaps the issue should be brought up with the fixed-point
> number library you're using, and they could fix their Enum instance to
> be more helpful.
Or just avoid Enum, and define "range" or something similar instead.
-k
--
If I haven't seen further, it is by standing in the footprints of giants
More information about the Haskell-Cafe
mailing list