<div dir="auto">Adding to Philip's "things worth noting": I think anyone sophisticated enough (and lucky enough) to have their most important performance bottleneck localized to a call to sortOn instead of sortWith (or vice versa) are also sophisticated enough to implement their own version when necessary.<div dir="auto"><br></div><div dir="auto">Consistent names, on the other hand, are useful to everyone, all the time.</div><div dir="auto"><br></div><div dir="auto">I don't think what I just said is a surprising insight for anyone, but I thought it would be useful to state it explicitly. :)</div><div dir="auto"><br></div><div dir="auto">-Bryan</div><div dir="auto"><br></div><div dir="auto">P.s. +1 to documenting performance differences, for those rare moments they matter.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 18 Feb 2020, 1.27 Philip Hazelden, <<a href="mailto:philip.hazelden@gmail.com">philip.hazelden@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr">On Mon, Feb 17, 2020 at 3:59 PM Carter Schonwald <<a href="mailto:carter.schonwald@gmail.com" target="_blank" rel="noreferrer">carter.schonwald@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div dir="auto">It seems like the *on family in general has a nontrivial increase in space usage and the only differences have to do with application specific time vs memory tradeoffs that need to measured at the application level.</div></div></blockquote><div><br></div><div>To be clear, this particular tradeoff isn't relevant for every *On function. Of the ones under discussion, it applies to sortWith, groupAllWith and groupAllWith1, but not groupWith or groupWith1.</div><div><br></div><div>Some things I think are worth noting:</div><div><br></div><div>* There must be lots of common functions that could choose different implementation tradeoffs, but we don't keep multiple versions of them around.</div><div>* The existing performance differences aren't documented. (Data.List.sortOn tells us that it only evaluates `f` once per element, but it doesn't tell us about the costs; the others don't mention performance at all.) I predict very few people currently choose between GHC.Exts.sortWith and Data.List.sortOn according to their performance needs.</div><div>* The Data.List.sortOn implementation is somewhat subtle and complicated. The NonEmpty.sortWith implementation is literally `sortBy . comparing` and GHC.Exts.sortWith isn't much more complicated. (`<span>sortWith</span> <span>f</span> <span>=</span> <span>sortBy</span> <span>(</span><span>\</span><span>x</span> <span>y</span> <span>-></span> <span>compare</span> <span>(</span><span>f</span> <span>x</span><span>)</span> <span>(</span><span>f</span> <span>y</span><span>)</span><span>)`; I don't know if there are reasons to prefer or disprefer this compared to `sortBy . comparing`.) If someone wants this behavior, it's not hard for them to get.</span></div><div><br></div><div>Based on these, I don't think there's much value in deliberately[1] making sure both implementations have a name, which is why I proposed to replace `sortWith` with `sortOn` instead of keeping them both around.</div><div><br></div><div>[1] Of course, there's value in not changing things once they're there. By "deliberately", I mean that if we weren't already in this situation, and someone proposed adding a separate function that was semantically equivalent to `sortOn` but implemented as `sortBy . comparing`, I don't think that would see much support.</div></div></div>
_______________________________________________<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>