
I am not super excited about library functions like comparing = (compare `on`) equating = ((==) `on`) It is rather knowledge how to use 'on', a programming pattern. The problem we have to solve is how we get a user searching for sortOn : Ord b => (a -> b) -> [a] -> [a] to find an explanation of the simple solution sortOn f = sortBy (compare `on` f) This problem of API explanation has been discussed on this list. Maybe instead of adding such simple functions to the library, one could put out a hoogle- and hayoo-indexed package that contains all such functions that could be expected to be in the library but are not since they have trivial implementations. Cheers, Andreas P.S.: In fact, `sortOn' would be more useful than `comparing' since it at least saves two words. On 18.07.2014 21:31, Henning Thielemann wrote:
Am 18.07.2014 21:26, schrieb Frerich Raabe:
In a similiar vein as with 'comparing', I think it would be nice if there was a function which encapsulates this use case, like
equating :: Eq b => (a -> b) -> a -> a -> Bool equating = on (==)
such that one can write
groupBy (equating snd)
I think it belongs to Data.Eq.
I have already added it to my own Data.Eq module:
http://hackage.haskell.org/package/utility-ht-0.0.10/docs/Data-Eq-HT.html
this way I do not need to depend on a new GHC version in order to use it.
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries
-- Andreas Abel <>< Du bist der geliebte Mensch. Department of Computer Science and Engineering Chalmers and Gothenburg University, Sweden andreas.abel@gu.se http://www2.tcs.ifi.lmu.de/~abel/