On Thu, Oct 25, 2001 at 10:01:57AM +0200, Ketil Malde wrote:
[Heavy snippage and editing]
From: Ketil Malde <ketil@ii.uib.no> Subject: Re: Enum class
i_succ' = succ i' -- ghc : 2147483648 -- hugs: -2147483648 I think Hugs is wrong. Integer shouldn't wrap. "Sigbjorn Finne" <sof@galconn.com> writes: Hugs is indeed wrong, I've checked in the same (obvious) fix that was made to GHC's Enum Integer instance a long time ago.
Uh - I meant wrong in an intuitive way, and I was corrected on the grounds that the Prelude defines ... <snippage> ... So apparently, it was the intention of the language designers that "infinite" lists defined by [b..] and the so-called succ only go from 2G long before they wrap, since toEnum and fromEnum maps to Ints and not Integers.
I think it's clear from the thread that the language designers did _not_ intend this, and that one should not use the default instances for the standard numeric classes. See Simon Peyton-Jones' recent post.
There's also been a longish thread about the fun consequences for floating point numbers, I can try to summarize if necessary. I, being a mere lay programmer, find it quite surprising that "succ" returns the next higher integer for positive floats, but the next higher *plus one* for negatives. Or that [a..b] produces a set of numbers outside the specified range (and indeed that these are defined at all for floating point numbers).
I agree that Enum instances for Float/Double are not likely to be useful. Best, Dylan Thurston