Proposal: Remove Semigroup and Monoid instances for Data.Map, Data.IntMap, Data.HashMap

David Feuer david.feuer at gmail.com
Wed Feb 14 15:07:52 UTC 2018


This, of course, is another argument for Kris's idea of just offering
a pile of newtypes, each with their own Semigroup (and sometimes
Monoid) instance.

On Wed, Feb 14, 2018 at 10:03 AM, Joachim Breitner
<mail at joachim-breitner.de> wrote:
> Hi,
>
> Am Mittwoch, den 14.02.2018, 09:47 -0500 schrieb Mario Blažević:
>>         I understand it's hard to grep, but can you guess how many of those
>> 40-80 uses of (<>) with the union meaning actually depend on the
>> left-biased semantics? I've looked at my code, and it turns out that
>> wherever this operation appears, the two maps are guaranteed to have
>> distinct keys.
>
> does this indicate the need for
>
>     disjointUnion :: IntMap a -> IntMap a -> IntMap a
>
> that throws an error when the maps are not disjoint? (run-time error
> only, because we are not doing theorem proving here…)
>
> One can get the effect with
>
>     unionWith (error "not disjoint)
>
> of course (and I have done so), but having `disjointUnion` in the API
> might remind people that they have to think about which variant they
> want.
>
> Cheers,
> Joachim
>
> --
> Joachim Breitner
>   mail at joachim-breitner.de
>   http://www.joachim-breitner.de/
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>


More information about the Libraries mailing list