
+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
Subject: Re: Maximum and Minimum monoids
To: Gabriel Gonzalez
Cc: libraries@haskell.org Message-ID: <20121227202510.GA24842@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