[commit: ghc] master: Add doc to (<$>) explaining its relationship to ($) (06b70ff)

git at git.haskell.org git at git.haskell.org
Fri Mar 11 12:27:24 UTC 2016


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/06b70ffc7b17bd34ea771b8be11574c4002db6c8/ghc

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

commit 06b70ffc7b17bd34ea771b8be11574c4002db6c8
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


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

06b70ffc7b17bd34ea771b8be11574c4002db6c8
 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