[commit: ghc] master: Doctests for Data.Tuple (f50e30e)

git at git.haskell.org git at git.haskell.org
Sat Aug 19 03:28:39 UTC 2017


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

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

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

commit f50e30e0e34487ae8bf49653875ed7c8d0afa791
Author: David Luposchainsky <dluposchainsky at gmail.com>
Date:   Fri Aug 11 10:37:55 2017 +0200

    Doctests for Data.Tuple


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

f50e30e0e34487ae8bf49653875ed7c8d0afa791
 libraries/base/Data/Tuple.hs | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/libraries/base/Data/Tuple.hs b/libraries/base/Data/Tuple.hs
index 372e2b8..569dd14 100644
--- a/libraries/base/Data/Tuple.hs
+++ b/libraries/base/Data/Tuple.hs
@@ -39,13 +39,32 @@ snd                     :: (a,b) -> b
 snd (_,y)               =  y
 
 -- | 'curry' converts an uncurried function to a curried function.
+--
+-- ==== __Examples__
+--
+-- >>> curry fst 1 2
+-- 1
 curry                   :: ((a, b) -> c) -> a -> b -> c
 curry f x y             =  f (x, y)
 
 -- | 'uncurry' converts a curried function to a function on pairs.
+--
+-- ==== __Examples__
+--
+-- >>> uncurry (+) (1,2)
+-- 3
+--
+-- >>> uncurry ($) (show, 1)
+-- "1"
+--
+-- >>> map (uncurry max) [(1,2), (3,4), (6,8)]
+-- [2,4,8]
 uncurry                 :: (a -> b -> c) -> ((a, b) -> c)
 uncurry f p             =  f (fst p) (snd p)
 
 -- | Swap the components of a pair.
 swap                    :: (a,b) -> (b,a)
 swap (a,b)              = (b,a)
+
+-- $setup
+-- >>> import Prelude hiding (curry, uncurry, fst, snd)



More information about the ghc-commits mailing list