[core libraries] Rename NonEmpty.groupWith/sortWIth to *On*

Philip Hazelden philip.hazelden at gmail.com
Sat Feb 15 18:58:39 UTC 2020


Hi,

On Sat, Feb 15, 2020 at 1:00 PM Carter Schonwald <carter.schonwald at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20200215/ebf85ac9/attachment.html>


More information about the Libraries mailing list