[Haskell-cafe] Re: Why is Day and Month bounded?

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Fri Jul 14 05:30:52 EDT 2006

"Johan Holmquist" <holmisen at gmail.com> wrote:

> If Day (and Month) where NOT instances of Bounded, the following would
> be possible:
> [Saturday .. Tuesday]
> => should return [Saturday, Sunday, Monday, Tuesday]
> => but returns []

This does seem like a reasonable argument to me.  Some enumerations are
semantically cyclic, rather than linear.

But how do you feel about the way it breaks some algebraic laws?
    fromEnum x < fromEnum (succ x)
    fromEnum x > fromEnum (pred x)
Of course, such laws are not explicitly stated anywhere in the
definition of the classes, so one would be foolish to rely on them in
any case.


More information about the Haskell-Cafe mailing list