Ranges and the Enum class

Aaron Denney wnoise at ofb.net
Mon Mar 20 20:47:41 EST 2006

On 2006-03-20, Wolfgang Jeltsch <wolfgang at jeltsch.net> wrote:
> Am Freitag, 17. März 2006 18:49 schrieb Ross Paterson:
>> [...]
>> Also, toEnum and fromEnum would make more sense mapping from and to
>> Integer.
> Why do we need toEnum and fromEnum at all?  As far as I know, they are merely 
> there to help people implement things like enumFrom.

Which could still be useful.

> It's often not clear 
> how toEnum and fromEnum should look like.  How should they be implemented for 
> Time.Day, for example?  Should the days corresponds to the integers 0 to 6 or 
> 1 to 7?

I believe that 0 to n-1 is the standard representation that deriving Enum currently

>> It seems that succ and pred are unused. 
> No, I use them.  In my opinion, it makes much more sense to write succ n than 
> n + 1.

Agreed, for non-arithmetical types.

Aaron Denney

More information about the Haskell-prime mailing list