summaryrefslogtreecommitdiff
path: root/libraries/base/Data/Tuple.hs
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/base/Data/Tuple.hs')
-rw-r--r--libraries/base/Data/Tuple.hs21
1 files changed, 20 insertions, 1 deletions
diff --git a/libraries/base/Data/Tuple.hs b/libraries/base/Data/Tuple.hs
index 372e2b8a86..569dd14da0 100644
--- a/libraries/base/Data/Tuple.hs
+++ b/libraries/base/Data/Tuple.hs
@@ -6,7 +6,7 @@
-- Module : Data.Tuple
-- Copyright : (c) The University of Glasgow 2001
-- License : BSD-style (see the file libraries/base/LICENSE)
---
+--
-- Maintainer : libraries@haskell.org
-- Stability : experimental
-- Portability : portable
@@ -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)