Opened 8 years ago

Closed 8 years ago

Last modified 6 years ago

#979 closed proposal (fixed)

Adding on

Reported by: nad Owned by:
Priority: normal Milestone:
Component: libraries/base Version: 6.6
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

The function on defined by

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

is convenient when using functions like sortBy: sortBy (compare `on` fst), for example. It also makes the code more readable.

Furthermore I consider on to be above the Fairbairn threshold,
since

  • we get rid of two lambdas,
  • we get rid of the duplication of p,
  • on has some nice algebraic properties (documented in the patch)
  • and, most importantly, it is easier at a glance to understand (*) `on` p than to understand \x y -> p x * p y (assuming one knows about on).

The main question seems to be which module to put the function in. Based on previous discussion on the libraries list I suggest creating a new module Control.Function containing on plus (initially) some other combinators (working solely on and with functions) from the Prelude.

Deadline for discussion: 2006-11-09.

Attachments (1)

on.patch (37.5 KB) - added by nad 8 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 8 years ago by nad

Changed the module name to Data.Function.

Changed 8 years ago by nad

comment:2 Changed 8 years ago by nad

  • Resolution set to fixed
  • Status changed from new to closed

Proposal discussion summary:

  • Consensus was reached that a module containing on plus some functions from the prelude should be added.
  • The module name Control.Function was not well received. A bunch of other names were suggested, and almost everyone accepted Data.Function.
  • It was discussed whether comparing (i.e. on compare) and/or equating (on (==)) should also be present in the libraries. Consensus was reached that either both or none of them should be there, and most people wanted to have them in the libraries. The function comparing is already in the libraries, but not equating. Complaints were raised about the name "equating", though, and no consensus was reached about an alternative name. Hence I leave the comparing/equating discussion open for another proposal.

comment:3 Changed 6 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:4 Changed 6 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.