
On 3/4/07, David Menendez
Jeffrey Yasskin writes:
I've created http://hackage.haskell.org/trac/ghc/ticket/1189 to suggest adding two Monoid instances around Maybe that, instead of accumulating things like most monoids, just pick the first or last piece of data they see.
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. Also, (getDual . foldMap (Dual . f)) is less readable than (getLast . foldMap (Last . f)). On the other hand, maybe the usual case is to just want any result, rather than specifically the left-most or right-most one, in which case providing the instance for Maybe directly saves typing. Thanks for the comment, Jeffrey