When I was talking about this on the IRC channel, I actually mentioned that I'd prefer (a -> Bool) -> [a] -> [a]. I guess you'd call that filterFirst or something.<div><br></div><div>Edward Kmett mentioned on IRC that all the fooBy functions follow a pattern, which is why deleteBy isn't like that.</div><div><div><br>On Sunday, June 21, 2015, David Feuer <<a href="mailto:david.feuer@gmail.com">david.feuer@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">+1, but what's wrong with just</p>
<p dir="ltr">whatever::(a->Bool)->[a]->[a]</p>
<p dir="ltr">Is this some subtle efficiency thing relating to closure creation?</p>
<div class="gmail_quote">On Jun 21, 2015 2:32 AM, "Grant Slatton" <<a href="javascript:_e(%7B%7D,'cvml','grantslatton@gmail.com');" target="_blank">grantslatton@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span style="font-size:12.8000001907349px">Right now the type of deleteBy is:</span><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">(a -> a -> Bool) -> a -> [a] -> [a]</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">That is, it takes an equality predicate, a value, and a list, and deletes the first element in the list such that the equality predicate returns true for the given value and the element.</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">This can be generalized to:</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">(a -> b -> Bool) -> a -> [b] -> [b]</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Example use case:</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">keyValues :: [(a, b)]</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">key :: a</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">deleteBy (\x (y, _) -> x == y) key keyValues</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Thanks</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Grant Slatton</div></div>
<br>_______________________________________________<br>
Libraries mailing list<br>
<a href="javascript:_e(%7B%7D,'cvml','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-bin/mailman/listinfo/libraries</a><br>
<br></blockquote></div>
</blockquote></div></div>