[GHC] #979: Adding on
GHC
trac at galois.com
Thu Nov 2 11:53:28 EST 2006
#979: Adding on
-------------------------------+--------------------------------------------
Reporter: nad | Owner:
Type: proposal | Status: new
Priority: normal | Milestone:
Component: libraries/base | Version: 6.6
Severity: normal | Keywords:
Difficulty: Unknown | Testcase:
Architecture: Unknown | Os: Unknown
-------------------------------+--------------------------------------------
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.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/979>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list