Proposal: Add missing Monoid for ZipList

Christopher Allen cma at bitemyapp.com
Sat Jul 25 22:02:02 UTC 2015


>We could as well use the Monoid list implementation for ZipLists.

We could, but that would be redundant and wouldn't fit what ZipList is for
as well.


On Sat, Jul 25, 2015 at 3:57 PM, Henning Thielemann <
lemming at henning-thielemann.de> wrote:

>
>
> On Sat, 25 Jul 2015, Christopher Allen wrote:
>
>
>> http://hackage.haskell.org/package/base-4.8.1.0/docs/Control-Applicative.html#t:ZipList
>>
>> There's a Monoid that matches what the Applicative for ZipList does that
>> seems to be missing.
>>
>> instance Monoid a => Monoid (ZipList a) where
>>   mempty  = pure mempty
>>   mappend = liftA2 mappend
>>
>> It's been brought up before:
>>
>> https://mail.haskell.org/pipermail/haskell-cafe/2009-October/067861.html
>>
>> Not only is it useful when it's the Monoid you want, but it serves an
>> educational purpose for highlighting the relationship between Monoid and
>> Applicative as well.
>>
>> Are there any good reasons not to have it?
>>
>
> The Monoid instance for lists is not related to Applicative list instance
> - so why should the instances for ZipList? We could as well use the Monoid
> list implementation for ZipLists. If there is no actual application for the
> instance I would leave it unimplemented.




-- 
Chris Allen
Currently working on http://haskellbook.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20150725/22bade72/attachment.html>


More information about the Libraries mailing list