Proposal: generalise Monoid's mconcat

David Feuer david.feuer at gmail.com
Mon Aug 31 19:01:45 UTC 2015


That bar will be particularly hard to exceed in the presence of toList.
On Aug 31, 2015 3:00 PM, "David Feuer" <david.feuer at gmail.com> wrote:

> The theory of mconcat is that it should handle monoids that need to be
> summed in some special way. I don't know if anyone actually uses it so,
> however. Still, Reid is right that the circular dependency sets a very high
> bar.
> On Aug 31, 2015 2:47 PM, "Reid Barton" <rwbarton at gmail.com> wrote:
>
>> On Mon, Aug 31, 2015 at 1:54 PM, Fermin Reig <ferminreig at fastmail.fm>
>> wrote:
>>
>>> We could generalise:
>>>
>>> mconcat:: [a] -> a
>>> mconcat = foldr mappend memtpy
>>>
>>> to:
>>>
>>> mconcat:: Foldable t => t a -> a
>>> mconcat = foldr mappend memtpy
>>> -- even
>>> -- mconcat = fold
>>>
>>
>> I don't understand the appeal of generalizing the type of a function when
>> the generalization already exists; but in this case it's not a viable
>> option anyways because mconcat is a class method of Monoid, and the
>> definition of the Foldable class already refers to Monoid. Creating a
>> circular dependency of Monoid on Foldable would be a headache best avoided.
>>
>> Regards,
>> Reid Barton
>>
>> _______________________________________________
>> Libraries mailing list
>> Libraries at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20150831/6c718ffc/attachment.html>


More information about the Libraries mailing list