[Haskell 98 editor hat on]
Michael said:
> I'm slightly puzzled about the definition of list enumerations in
> GHC (and possibly other Haskell implementations)...
>
> ``[0.0, 2 .. 9] :: [Float]''
> ==> [0.0, 2.0, 4.0, 6.0, 8.0, 10.0]
Lennart Augustsson wrote:
| > By definition, if you follow the standard you can't be wrong. :)
| > But the standard can be wrong. Perhaps this is a typo in the report?
George replied:
| I think I looked at this a while back. The standard is
| kaput. It gets even worse if you try to make sense of the definitions of
succ and
| pred as applied to floating-point number. My suggestion: get rid of Enum
on
| floating-point numbers. Maybe it'll make floating point loops a little
| lengthier to code, but at least it will be clear what exactly is being
coded.
Personally, I heartily agree that Float/Double shouldn't be in Enum. But
the H98 ctte specifically left it so, and I can't change that (definitely
not a typo).
The report says clearly that [a, b..c] can produce a result as large as
c+(b-a)/2, but no larger. You may think it's silly to produce a result
bigger
than c, but the difficulty is that you want to *include* c, and that's
tricky in
floating point.
Bottom line: I don't like it either, but I don't think it's a typo. Feel
free to suggest
a typo-level of improvement! I will use my dictatorial powers (doubtless
after
democratic consultation) to decide if it's really a typo.
Simon