summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorGabriel Lebec <glebec@gmail.com>2018-04-07 12:57:36 -0400
committerBen Gamari <ben@smart-cactus.org>2018-04-07 13:30:15 -0400
commit8b823f270e53627ddca1a993c05f1ab556742d96 (patch)
treea9efc6f5a8bbbb97c9d295e86e38fa4c2c5a4dde /libraries
parenta5bfb7e143d826db310f5c632a90d39de62c7aa3 (diff)
downloadhaskell-8b823f270e53627ddca1a993c05f1ab556742d96.tar.gz
docs(Data.Function): fix and augment `on` annotation
Diffstat (limited to 'libraries')
-rw-r--r--libraries/base/Data/Function.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/libraries/base/Data/Function.hs b/libraries/base/Data/Function.hs
index ccc58c74ac..c54e81facc 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