Philip,

Here is the documentation for Generalized List Comprehensions that mentions sortWith: https://downloads.haskell.org/ghc/latest/docs/html/users_guide/glasgow_exts.html#generalised-sql-like-list-comprehensions

The asymmetry between Data.List and Data.List.NonEmpty is unfortunate. I think my preference would be a non-breaking change where groupOn is added to Data.List.NonEmpty effectively as an alias for groupWith and they would both stay forever. I've not looked at the semantic difference between sortWith and sortOn, so I'm not sure which of those should be implemented with the other, but ideally, I would like to see both of them there.

On Sat, Feb 15, 2020 at 1:59 PM Philip Hazelden <philip.hazelden@gmail.com> wrote:
Hi,

On Sat, Feb 15, 2020 at 1:00 PM Carter Schonwald <carter.schonwald@gmail.com> wrote:
Pedantic point : when you say semantics, it might be less confusing and more precise to performance tradeoffs.

Apologies, but I'm not sure what you mean here. Could you rephrase?
 
My English language and naive preference is to assume *With functions grammar better.  Or *by. I think the *on idiom is younger relatively.  

I don't personally have an a particular preference between *With and *On, just a preference for consistency. My proposal isn't motivated by the english meanings of the words "with" and "on", just by (my perception of) their current usage in the ecosystem. If *With was used in most places, and *On was used in Data.List.NonEmpty, then I'd recommend switching NonEmpty to *With.

(*By is already taken: `sortBy`, `nubBy`, `groupBy` and so on. That does seem to be already consistent.)

An advantage of *On is that it reflects how the functions can be defined using the `on` function:

    sortOn f = sortBy (compare `on` f)
    groupOn f = groupBy ((==) `on` f)

Historically, it does look like *With has been in use longer. (It looks like `sortOn` has been in base since 4.8 (2015), and in the "extra" package since the very first version 0.1 in 2014. `sortWith` has been in GHC.Exts since at least base 4.0 in 2009.)

But again, neither of those points factors into my motivation here.
 
Can I challenge you to reflect on what challenge  you are trying to address with this proposal and if there’s a course of action that you feel improves everything but breaks no code ?

I suppose that simply adding the new names, marking the old ones as deprecated, and then never actually removing the old ones, would work for that.
 
  And what would make the change an improvement for software using these modules already 

Well, a small one is that it would make that software slightly easier to read for people who recognize the *On convention but not the *With one. There's also a chance it would make a small number of people notice that they were using a function that had different semantics from what they thought, catching bugs that hadn't previously surfaced.

But I don't think there's any version of this proposal that would accomplish this in any significant way. Improving existing software isn't really the point.
_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


--
-Andrew Thaddeus Martin