Proposal: Add First and Last wrappers around Maybe to
Data.Monoid
Jan-Willem Maessen
jmaessen at alum.mit.edu
Wed Mar 7 22:38:13 EST 2007
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 <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 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2425 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/libraries/attachments/20070307/2bee79c7/smime.bin
More information about the Libraries
mailing list