Repair to floating point enumerations?
ndmitchell at gmail.com
Tue Dec 9 11:37:58 EST 2008
Bringing up an old thread, but this issue just bit me in real life:
[0, 2.5 .. 3.75 ] = [0, 2.5, 5.0]
I was comparative testing some C++ and some Haskell, and its a shame
when its the Haskell that is clearly wrong! I don't think any end
decision was reached in this thread, but I think this is sufficiently
incorrect to call the Haskell 98 behaviour a bug.
On Wed, Oct 22, 2008 at 10:11 AM, Simon Marlow <marlowsd at gmail.com> wrote:
> Malcolm Wallace wrote:
>> Phil proposes that, although retaining the instances of Enum for Float
>> and Double, we simplify the definitions of the numericEnumFrom family:
>> numericEnumFromThenTo :: (Fractional a, Ord a) => a -> a -> a -> [a]
>> numericEnumFrom = iterate (+1)
>> numericEnumFromThen n m = iterate (+(m-n)) n
>> numericEnumFromTo n m = takeWhile (<= m) (numericEnumFrom n)
>> numericEnumFromThenTo n m p = takeWhile (<= p) (numericEnumFromThen n m)
> I'll leave it to the floating-point experts to decide exactly what to do
> here for Haskell' (but I note that David Roundy's version looks better than
> the iterate version above, because the errors won't accumulate).
>> But as maintainer and bug-fixer of the Haskell'98 Report, I have also
>> been asked whether we should make this change retrospectively to the
>> Haskell'98 language (as a "typo"). Since it involves not merely an
>> ordinary library function, but a Prelude function, and moreover a
>> function that is used in the desugaring of syntax, it is less clear to
>> me whether to alter Haskell'98.
> We definitely can't make breaking changes to Haskell 98; this would be much
> more than a "typo".
> However, this does give us a problem if we decide to make a change here for
> H', as Neil points out, because there would be two mutually-incompatible
> instances for Enum Float. We'd need to have a clear distinction between
> programs that are Haskell 98 and those that are not, with only the former
> allowed to use the haskell98 package.
> Haskell-prime mailing list
> Haskell-prime at haskell.org
More information about the Haskell-prime