[commit: ghc] master: add example documentation for tuple Applicative (f57bd2a)

git at git.haskell.org git at git.haskell.org
Mon Mar 6 22:26:35 UTC 2017


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

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

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

commit f57bd2ae8fc787f14aeafa3f2f7ded253456528c
Author: GinBaby <jdog74 at gmail.com>
Date:   Mon Mar 6 13:43:57 2017 -0500

    add example documentation for tuple Applicative
    
    Reviewers: austin, hvr, bgamari, dfeuer
    
    Reviewed By: dfeuer
    
    Subscribers: dfeuer, thomie
    
    Differential Revision: https://phabricator.haskell.org/D3284


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

f57bd2ae8fc787f14aeafa3f2f7ded253456528c
 libraries/base/Control/Applicative.hs | 2 +-
 libraries/base/GHC/Base.hs            | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libraries/base/Control/Applicative.hs b/libraries/base/Control/Applicative.hs
index 8883818..406f086 100644
--- a/libraries/base/Control/Applicative.hs
+++ b/libraries/base/Control/Applicative.hs
@@ -106,7 +106,7 @@ instance (ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b) where
 newtype ZipList a = ZipList { getZipList :: [a] }
                   deriving ( Show, Eq, Ord, Read, Functor
                            , Foldable, Generic, Generic1)
--- See Data.Traversable for Traversabel instance due to import loops
+-- See Data.Traversable for Traversable instance due to import loops
 
 -- | @since 2.01
 instance Applicative ZipList where
diff --git a/libraries/base/GHC/Base.hs b/libraries/base/GHC/Base.hs
index e07c077..2f155c6 100644
--- a/libraries/base/GHC/Base.hs
+++ b/libraries/base/GHC/Base.hs
@@ -327,7 +327,14 @@ instance Monoid a => Monoid (Maybe a) where
   m `mappend` Nothing = m
   Just m1 `mappend` Just m2 = Just (m1 `mappend` m2)
 
--- | @since 2.01
+-- | For tuples, the 'Monoid' constraint on @a@ determines
+-- how the first values merge.
+-- For example, 'String's concatenate:
+--
+-- > ("hello ", (+15)) <*> ("world!", 2002)
+-- > ("hello world!",2017)
+--
+-- @since 2.01
 instance Monoid a => Applicative ((,) a) where
     pure x = (mempty, x)
     (u, f) <*> (v, x) = (u `mappend` v, f x)



More information about the ghc-commits mailing list