[Haskell-cafe] instance Enum Double considered notentirelygreat?
Iavor Diatchki
iavor.diatchki at gmail.com
Tue Sep 27 18:47:31 CEST 2011
Hello,
On Tue, Sep 27, 2011 at 8:49 AM, Chris Smith <cdsmith at gmail.com> wrote:
> You could calculate the entire range using Rational and then convert
> each individual value after the fact. That doesn't seem like a
> reasonable default, since it has a runtime performance cost. Of course
> you're welcome to do it when that's what you need.
>
>> last ([0.1, 0.2 .. 0.5]) == 0.5
> False
>
>> last (map fromRational [0.1, 0.2 .. 0.5]) == 0.5
> True
>
As Ross pointed out in a previous e-mail the instance for Rationals is
also broken:
> last (map fromRational [1,3 .. 20])
> 21.0
-Iavor
More information about the Haskell-Cafe
mailing list