<div dir="ltr">Minor nomenclature note: disjoint union has a <a href="https://en.wikipedia.org/wiki/Disjoint_union">specific meaning</a> in set theory which is different than how its being used here.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 14, 2018 at 8:13 AM, Mario Blažević <span dir="ltr"><<a href="mailto:mblazevic@stilo.com" target="_blank">mblazevic@stilo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 2018-02-14 10:07 AM, David Feuer wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This, of course, is another argument for Kris's idea of just offering<br>
a pile of newtypes, each with their own Semigroup (and sometimes<br>
Monoid) instance.<br>
</blockquote>
<br></span>
        I would gladly use disjointUnion where appropriate, but I don't think I'd ever use a newtype providing the same effect. Why? There are two situations when I depend on union* or (<>) on maps:<br>
<br>
1. Directly at the top level, where I can use either union or (<>) on two known maps. In this situation I often use (<>) only because (a <> b) is shorter and easier to read then (union a b), but that criterion points the other way if I have to say (fromDisjoint (Disjoint a <> Disjoint b)) instead of (disjointUnion a b).<br>
<br>
2. Indirectly when folding a Foldable collection of maps. In this case I have no choice but to use (<>), but I really can't think of any occasion when all maps in the collection are guaranteed to have distinct keys.<span class="im HOEnZb"><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Wed, Feb 14, 2018 at 10:03 AM, Joachim Breitner<br>
<<a href="mailto:mail@joachim-breitner.de" target="_blank">mail@joachim-breitner.de</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
Am Mittwoch, den 14.02.2018, 09:47 -0500 schrieb Mario Blažević:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
         I understand it's hard to grep, but can you guess how many of those<br>
40-80 uses of (<>) with the union meaning actually depend on the<br>
left-biased semantics? I've looked at my code, and it turns out that<br>
wherever this operation appears, the two maps are guaranteed to have<br>
distinct keys.<br>
</blockquote>
<br>
does this indicate the need for<br>
<br>
     disjointUnion :: IntMap a -> IntMap a -> IntMap a<br>
<br>
that throws an error when the maps are not disjoint? (run-time error<br>
only, because we are not doing theorem proving here…)<br>
<br>
One can get the effect with<br>
<br>
     unionWith (error "not disjoint)<br>
<br>
of course (and I have done so), but having `disjointUnion` in the API<br>
might remind people that they have to think about which variant they<br>
want.<br>
</blockquote></blockquote></span><div class="HOEnZb"><div class="h5">
______________________________<wbr>_________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/libraries</a><br>
</div></div></blockquote></div><br></div>