On 19/05/2010, at 23:44, Ben Millwood wrote: > On Wed, May 19, 2010 at 10:57 AM, Serguey Zefirov <sergu...@gmail.com> wrote: >> >> PS >> Rationals: >> Prelude> [1,1+2/3..10] :: [Rational] >> [1 % 1,5 % 3,7 % 3,3 % 1,11 % 3,13 % 3,5 % 1,17 % 3,19 % 3,7 % 1,23 % >> 3,25 % 3,9 % 1,29 % 3,31 % 3] >> >> Same result. > > This sounds like a bug to me. The section of the Haskell Report that > deals with the Enum class mentions Float and Double, not Rational, and > there's really no sensible reason why Rationals would exhibit this > behaviour given that they don't have rounding error.
From Section 12.1 of the Library Report: instance (Integral a) => Enum (Ratio a) where succ x = x+1 pred x = x-1 toEnum = fromIntegral fromEnum = fromInteger . truncate -- May overflow enumFrom = numericEnumFrom -- These numericEnumXXX functions enumFromThen = numericEnumFromThen -- are as defined in Prelude.hs enumFromTo = numericEnumFromTo -- but not exported from it! enumFromThenTo = numericEnumFromThenTo The numericEnum functions are defined in Section 8 of the Language Report and have semantics required for Float and Double. Roman _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe