<div dir="ltr"><div>What would be use-cases for (2)? As Joachim pointed out, for any reasonable data type inserting an equal element should have no difference.</div><div><br></div>For (3) I'd be in favor of<div><br><div><div> alterF :: (Functor f, Ord a) => a -> (Bool -> f Bool) -> Set a -> f (Set a)</div></div><div><br></div><div>(with any reasonable name) which'd allow to examine a set and possibly modify it in one traversal. It should be smart enough not to modify the set at all if the output of a given function is the same as its input. A<span style="font-size:13.63636302948px">nd it'd also fit with lens. In particular, query+delete could be then expressed as</span></div><div><span style="font-size:13.63636302948px"><br></span></div><div><span style="font-size:13.63636302948px"> </span>memberDelete :: (Ord a) => a -> Set a -> (Bool, Set a)</div><div><span style="font-size:13.63636302948px"> </span>memberDelete k = alterF k (flip (,) False)</div><div><span style="font-size:13.63636302948px"><br></span></div><div><span style="font-size:13.63636302948px"> Petr</span></div><div><br><div class="gmail_quote">čt 5. 3. 2015 v 23:59 odesílatel David Feuer <<a href="mailto:david.feuer@gmail.com">david.feuer@gmail.com</a>> napsal:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">There are a few rather conspicuously missing features:<br>
<br>
1. A way to take the intersection of a list of sets. This shouldn't<br>
really be a big deal, and it already exists for unions, but the<br>
intersection version should probably sort the sets by size before<br>
folding, or otherwise try to do something smart.<br>
<br>
2. A way to insert an element if an == one is not already present<br>
(insert replaces an existing one with a new one). Currently, as far as<br>
I can tell, this can only be done using either<br>
<br>
if e `member` s then s else insert e s<br>
which potentially descends the tree twice for no reason<br>
<br>
or<br>
<br>
s `union` singleton e<br>
<br>
which is documented as being O(|s|+1), although I wouldn't be shocked<br>
if the documentation were too pessimistic in this case.<br>
<br>
3. A way to delete an element and simultaneously find out whether it<br>
was in the set.<br>
<br>
David Feuer<br>
______________________________<u></u>_________________<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" target="_blank">http://mail.haskell.org/cgi-<u></u>bin/mailman/listinfo/libraries</a><br>
</blockquote></div></div></div></div>