Maximum and Minimum monoids

John Lato jwlato at
Fri Dec 28 01:29:54 CET 2012

+1 for something like this.  I've written these at least once, and
encountered them on a few more occasions.

I would prefer specific types as Roman suggests, I think.  I prefer to
match on Plus/MinusInfinity rather than going via Maybe.

John L.

> From: Roman Cheplyaka <roma at>
> Subject: Re: Maximum and Minimum monoids

To: Gabriel Gonzalez <gabriel439 at>
> Cc: libraries at
> Message-ID: <20121227202510.GA24842 at sniper>
> Content-Type: text/plain; charset=us-ascii
> Wouldn't it be better to have a real algebraic type instead of wrapping
> Maybe?
> Something like
>   data Maximum a = MinusInfinity | Maximum a
>   data Minimum a = PlusInfinity  | Minimum a
> Maximum x is more concise than Maximum (Just x), and MinusInfinity is
> more descriptive than Maximum Nothing. getMaximum/getMinimum functions
> can still return Maybes.
> Anyway, I'm +1 to having something along these lines.
> Roman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Libraries mailing list