Maximum and Minimum monoids
jwlato at gmail.com
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.
> From: Roman Cheplyaka <roma at ro-che.info>
> Subject: Re: Maximum and Minimum monoids
To: Gabriel Gonzalez <gabriel439 at gmail.com>
> Cc: libraries at haskell.org
> 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
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libraries