darcs patch: Add equating p x y = p x == p y

Nils Anders Danielsson nad at cs.chalmers.se
Wed Oct 11 10:46:05 EDT 2006

On Wed, 11 Oct 2006, Duncan Coutts <duncan.coutts at worc.ox.ac.uk> wrote:

> Wed Oct 11 15:14:32 BST 2006  Duncan Coutts <duncan.coutts at worc.ox.ac.uk>
>   * Add equating p x y = p x == p y
>   Just as useful as the 'comparing' function from Data.Ord,
>   but for cases where we check equality rather than ordering.
>   Use like: groupBy (equating fst)

Instead of adding 'comparing', 'equating' etc., I suggest that you add
the more general 'on', which is just as easy to use. ('on' has been
mentioned on the lists a couple of times before.)

  (*) `on` f = \x y -> f x * f y

  groupBy ((==) `on` fst)
  sortBy (compare `on` snd)
  maximumBy (customCompare `on` f)


More information about the Libraries mailing list