Proposal: Add First and Last wrappers around Maybe to Data.Monoid

Stefan O'Rear stefanor at cox.net
Tue Mar 6 18:29:37 EST 2007


On Tue, Mar 06, 2007 at 06:08:02PM +0000, Ross Paterson wrote:
> On Mon, Mar 05, 2007 at 02:11:58PM -0800, Jeffrey Yasskin wrote:
> > On 3/4/07, David Menendez <zednenem at psualum.com> 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 is (by Wikipedia standards) a very important instance - it
corresponds to the process of creating a monoid from a semigroup by
adjoining an element and defining it to be the identity. 

Stefan


More information about the Libraries mailing list