
On Mar 6, 2007, at 1:08 PM, Ross Paterson wrote:
On Mon, Mar 05, 2007 at 02:11:58PM -0800, Jeffrey Yasskin wrote:
On 3/4/07, David Menendez
wrote: Rather than have two wrappers, I say make the a Monoid instance for Maybe using a left-biased choice (like the MonadPlus instance).
Then we would get right-biased choice for free with the Dual wrapper.
That's a reasonable idea, but I chose against it in the proposal because it arbitrarily picks one of the two sensible monoids for Maybe, which I'm worried will confuse users, especially since Haddock doesn't currently provide documentation for instances.
There is another, combining two Justs using a Monoid instance on the argument. It could be argued that this is an even better candidate for the "obvious" instance on Maybe.
This counts as my most used function on Maybe not provided by the libraries, ranking up with generalized list merge in my rogue's gallery of frequently-resurrected functions. I use the "imposed identity" version (cf other discussion on this thread), where a single Just argument is carried to the result. The "imposed zero" version is just liftM2 on Maybe (which I pretty much never need; why *do* people find this so useful?). -Jan-Willem Maessen