[commit: ghc] ghc-8.0: Add doc to (<$>) explaining its relationship to ($) (8358be7)

git at git.haskell.org git at git.haskell.org
Sat Mar 12 21:45:55 UTC 2016


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

On branch  : ghc-8.0
Link       : http://ghc.haskell.org/trac/ghc/changeset/8358be725a19826d862941c2a6e002aa4b366abf/ghc

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

commit 8358be725a19826d862941c2a6e002aa4b366abf
Author: Chris Martin <ch.martin at gmail.com>
Date:   Fri Mar 11 10:40:16 2016 +0100

    Add doc to (<$>) explaining its relationship to ($)
    
    Reviewers: bgamari, hvr, austin
    
    Reviewed By: bgamari
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D1989
    
    (cherry picked from commit 06b70ffc7b17bd34ea771b8be11574c4002db6c8)


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

8358be725a19826d862941c2a6e002aa4b366abf
 libraries/base/Data/Functor.hs | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libraries/base/Data/Functor.hs b/libraries/base/Data/Functor.hs
index 72ee965..8eba29e 100644
--- a/libraries/base/Data/Functor.hs
+++ b/libraries/base/Data/Functor.hs
@@ -33,6 +33,15 @@ infixl 4 <$>
 
 -- | An infix synonym for 'fmap'.
 --
+-- The name of this operator is an allusion to '$'.
+-- Note the similarities between their types:
+--
+-- >  ($)  ::              (a -> b) ->   a ->   b
+-- > (<$>) :: Functor f => (a -> b) -> f a -> f b
+--
+-- Whereas '$' is function application, '<$>' is function
+-- application lifted over a 'Functor'.
+--
 -- ==== __Examples__
 --
 -- Convert from a @'Maybe' 'Int'@ to a @'Maybe' 'String'@ using 'show':



More information about the ghc-commits mailing list