Proposal: add 'equating' function to Data.List
Henning Thielemann
schlepptop at henning-thielemann.de
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:
http://hackage.haskell.org/package/utility-ht-0.0.10/docs/Data-List-Key.html
I have also a version of 'groupBy' that returns a list of non-empty lists:
http://hackage.haskell.org/package/non-empty-0.2/docs/Data-NonEmpty-Mixed.html#v:groupBy
It's all Haskell 98.
More information about the Libraries
mailing list