|
Re: unexpected arithmetic sequence and deriving Enum behaviour: msg#00139lang.haskell.glasgow.bugs
Hi Laszlo, Laszlo Nemeth wrote: Consider the following code fragment: Why do you say that? Can you give a pointer to the relevant text in the report? I can't see anything wrong here. The minimal complete instance of Enum consists of toEnum and fromEnum, which yours does. > and there is no definition for 'enumFrom'. [ core snipped ]
This is because, as per the report, GHC defines the default method for enumFrom as: enumFrom x = map toEnum [fromEnum x ..] the sequence on the RHS is at type Int, and hence doesn't terminate until it reaches maxBound::Int. Perhaps you expect that, because your type is also an instance of Bounded, that enumFrom should behave differently. However, there can only be one default method for enumFrom. Perhaps this isn't a bug, but definitely an undocumented and rather unexpected 'feature'. This is with ghc-6.4 onwards, and I haven't checked earlier versions. You're right, I don't think it's a bug. Also, if you had derived Enum instead of defining it, you would have got a version that behaved in the "expected" way. You defined an instance of Enum yourself, and got exactly what you asked for! Cheers, Simon
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | unexpected arithmetic sequence and deriving Enum behaviour, Laszlo Nemeth |
|---|---|
| Next by Date: | Re: unexpected arithmetic sequence and deriving Enum behaviour, Stefan Holdermans |
| Previous by Thread: | unexpected arithmetic sequence and deriving Enum behaviour, Laszlo Nemeth |
| Next by Thread: | Re: unexpected arithmetic sequence and deriving Enum behaviour, Stefan Holdermans |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |