Proposal: add 'equating' function to Data.List

Henning Thielemann schlepptop at
Fri Jul 18 20:07:14 UTC 2014

Am 18.07.2014 21:57, schrieb Greg Weber:

> I think the `By` functions that expect a Bool are all cumbersome because
> they are too flexible. 100% of the time I personally use these functions
> I want to use Ord or Eq.
> What I would like to see is a function groupOn next to groupBy.
> groupOn :: Eq b => (a -> b) -> [a] -> [[a]]
> Then equating is no longer needed, and one just writes: groupOn snd
> I believe this style also gives better opportunity for optimization
> (Scwartzian transform).

It's also in my utility package:

I have also a version of 'groupBy' that returns a list of non-empty lists:

It's all Haskell 98.

More information about the Libraries mailing list