Proposal: Add `maxOn` and `minOn` functions to Data.Ord

Evan Laforge qdunkan at
Fri May 27 20:04:03 UTC 2016

On Fri, May 27, 2016 at 12:02 PM, Edward Kmett <ekmett at> wrote:
> Note: in general we have chosen to supply By methods, rather than On methods, because he on combinator can be used to get one in terms of the other. We explicitly added sortOn because it can use a Schwartzian transform to be more efficient than sortBy (comparing `on` f).

I've noticed that I've needed the "by" only very rarely, while I use
"on" variants almost every time.  Specifically, for sorting, grouping
by key, max, min, and total versions of maximum and minimum, all
extremely useful.  I don't mind their absence from Data.List because I
have them all in a local library and I tend to think a local library
makes everyone happier than trying to put the union of everything
everyone wants in the standard library.

But I wonder if others have the same experience, and if it isn't one
of those cases where haskell prioritized more general over more

I also like the On suffix because it can be applied universally to all
functions that take a key function.

But anyway, there is also a data-ordlist package out there that has a
bunch of utilities along those lines, perhaps its maintainer would be
receptive to maxOn and minOn.

More information about the Libraries mailing list