[commit: ghc] master: docs(Data.Function): fix and augment `on` annotation (8b823f2)

git at git.haskell.org git at git.haskell.org
Sat Apr 7 19:45:42 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/8b823f270e53627ddca1a993c05f1ab556742d96/ghc

>---------------------------------------------------------------

commit 8b823f270e53627ddca1a993c05f1ab556742d96
Author: Gabriel Lebec <glebec at gmail.com>
Date:   Sat Apr 7 12:57:36 2018 -0400

    docs(Data.Function): fix and augment `on` annotation


>---------------------------------------------------------------

8b823f270e53627ddca1a993c05f1ab556742d96
 libraries/base/Data/Function.hs | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libraries/base/Data/Function.hs b/libraries/base/Data/Function.hs
index ccc58c7..c54e81f 100644
--- a/libraries/base/Data/Function.hs
+++ b/libraries/base/Data/Function.hs
@@ -50,18 +50,21 @@ infixl 1 &
 fix :: (a -> a) -> a
 fix f = let x = f x in x
 
--- | @((==) \`on\` f) x y = f x == f y@
+-- | @'on' b u x y@ runs the binary function `b` /on/ the results of applying unary function `u` to two arguments `x` and `y`. From the opposite perspective, it transforms two inputs and combines the outputs.
+--
+-- @((+) \``on`\` f) x y = f x + f y@
 --
 -- Typical usage: @'Data.List.sortBy' ('compare' \`on\` 'fst')@.
-
+--
 -- Algebraic properties:
 --
--- * @(*) \`on\` 'id' = (*)@ (if @(*) &#x2209; {&#x22a5;, 'const' &#x22a5;}@)
+-- * @(*) \`on\` 'id' = (*) -- (if (*) &#x2209; {&#x22a5;, 'const' &#x22a5;})@
 --
 -- * @((*) \`on\` f) \`on\` g = (*) \`on\` (f . g)@
 --
 -- * @'flip' on f . 'flip' on g = 'flip' on (g . f)@
-
+on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
+(.*.) `on` f = \x y -> f x .*. f y
 -- Proofs (so that I don't have to edit the test-suite):
 
 --   (*) `on` id
@@ -102,9 +105,6 @@ fix f = let x = f x in x
 -- =
 --   flip on (g . f)
 
-on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
-(.*.) `on` f = \x y -> f x .*. f y
-
 
 -- | '&' is a reverse application operator.  This provides notational
 -- convenience.  Its precedence is one higher than that of the forward



More information about the ghc-commits mailing list