<div dir="auto">Map merges can do even more, because they work with arbitrary Applicative functors. So a functor like<div dir="auto"><br></div><div dir="auto">    data Triple a = Triple a a a</div><div dir="auto">    instance Applicative Triple where</div><div dir="auto">      pure a = Triple a a a</div><div dir="auto">      liftA2 f (Triple x y z) (Triple p q r) = Triple (f x p) (f y q) (f z r)</div><div dir="auto"><br></div><div dir="auto">can be used to calculate union, intersection, *and* symmetric difference all in one go. I should just bite the bullet and implement that for sets.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 26, 2020, 1:16 PM Andrew Lelechenko <<a href="mailto:andrew.lelechenko@gmail.com">andrew.lelechenko@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 18 Jun 2020, at 23:42, Bardur Arantsson <<a href="mailto:spam@scientician.net" target="_blank" rel="noreferrer">spam@scientician.net</a>> wrote:<br>
> I think it's probably going to be useful, but I would suggest an<br>
> algorithm which actually returns each of the terms here (as a tuple), i.e.<br>
> <br>
>   The "added" bits<br>
>   The "removed" bits<br>
>   The "common" bits<br>
> <br>
> This may not be *that* useful for sets per se, but I've lost count of<br>
> how often I've had to implement a similar thing for maps.<br>
<br>
<br>
This is probably orthogonal to my proposal here, because it does not improve the performance of symmetricDifference. Maps are more flexible in this aspect, because there are merge tactics, which allow to encode any set operation.<br>
<br>
Best regards,<br>
Andrew<br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank" rel="noreferrer">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div>