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

Henning Thielemann lemming at henning-thielemann.de
Fri Jul 14 07:12:02 EDT 2006

On Fri, 14 Jul 2006, Johan Holmquist wrote:

> from Henning Thielemann:
> > Since the days are cycling, what is more natural about your result
> > compared to my one?
> I would prefer the one without any repetitions.
> > I assume the Bounded instance exists in order to allow loops like
> >   liftM2 (,) [0..] [minBound .. (maxBound::System.Time.Month)]
> Would not "liftM2 (,) [0..] [Sunday .. Saturday]" do the trick?

You mean
  liftM2 (,) [0..] [January .. December] ?
    (I chose Months in order to get a sensible example.)

I assume that the Bounded class exists in order to stay independent from
the particular type. With minBound and maxBound you do not rely on whether
the counting starts on Sunday or Monday if you only want to do something
for all days.

> Sure there are subtleties, like what should [Monday .. Monday] return, either:
> [Monday] or
> [Monday, Tuesday ... Sunday]
> but to settle for one would be ok to me.

You mean  [Monday, Tuesday ... Sunday, Monday] ?

I also think that there must be a possibility to obtain an empty list.
Now I get it with
 [Monday .. Sunday]
but I assume that you prefer
 [Monday, Tuesday ... Sunday]

More information about the Haskell-Cafe mailing list