[containers] Proposal: Change to the Data.Map Monoid

John Lato jwlato at gmail.com
Tue May 20 19:52:12 UTC 2014


On May 20, 2014 11:49 AM, "Andreas Abel" <abela at chalmers.se> wrote:
>
> I think the Monoid instance for Data.Map should be *removed*.

+1 to removing the instance.

I'm currently ambivalent towards adding newtypes over Map with Monoid
instances.

John L.

>
> Reason:  there are at least two meaningful instances.
>
> And, the documentation for the current instance is as out spoken as the
fish in my non-existent aquarium:
>
> ""
>
> So, to use the Monoid instance, one has to consult the source code, just
to see:
>
> instance (Ord k) => Monoid (Map k v) where
>     mempty  = empty
>     mappend = union
>     mconcat = unions
>
> Fantastic!  I could never have though of these cunning implementations
myself (sorry, sarcasm, I know).
>
> Why not trash these oneliners and free the Monoid instance for whatever
the user wants it to do?
>
> Of course, I know, pragmatics, we cannot just remove functionality, might
break existing code.
>
> But at least not silently.
>
> Maybe this could be sneaked in with another incompatible change of the
Data.Map package?  And after five years of having no Monoid instance, one
could think of adding the most useful one.  Or rather not, but have two
newtypes with the respective meaningful implementations.  Which we can also
have here and now.
>
>
> On 19.05.2014 07:05, Henning Thielemann wrote:
>>
>> Am 19.05.2014 02:05, schrieb Nick Partridge:
>>
>>> instance Monoid v => Monoid (Map k v) where
>>>      mappend = unionWith mappend
>>>
>>> This lets us build up maps with values in a useful Monoid, and mappend
>>> them with gusto.
>>
>>
>> This was discussed two years ago:
>>    http://www.haskell.org/pipermail/libraries/2012-April/017743.html
>>
>> That said, I'd also prefer your instance.
>>
>> _______________________________________________
>> Libraries mailing list
>> Libraries at haskell.org
>> http://www.haskell.org/mailman/listinfo/libraries
>>
>
>
> --
> Andreas Abel  <><      Du bist der geliebte Mensch.
>
> Department of Computer Science and Engineering
> Chalmers and Gothenburg University, Sweden
>
> andreas.abel at gu.se
> http://www2.tcs.ifi.lmu.de/~abel/
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140520/22911aa9/attachment.html>


More information about the Libraries mailing list