1
{-# OPTIONS_GHC -XNoImplicitPrelude #-}
2
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
3
-- XXX -fno-warn-unused-imports needed for the GHC.Tuple import below. Sigh.
4
-----------------------------------------------------------------------------
7
-- Copyright : (c) The University of Glasgow 2001
8
-- License : BSD-style (see the file libraries/base/LICENSE)
10
-- Maintainer : libraries@haskell.org
11
-- Stability : experimental
12
-- Portability : portable
14
-- The tuple data types, and associated functions.
16
-----------------------------------------------------------------------------
19
( fst -- :: (a,b) -> a
20
, snd -- :: (a,b) -> a
21
, curry -- :: ((a, b) -> c) -> a -> b -> c
22
, uncurry -- :: (a -> b -> c) -> ((a, b) -> c)
23
, swap -- :: (a,b) -> (b,a)
33
, (,,,,,,,,,)(..)
34
, (,,,,,,,,,,)(..)
35
, (,,,,,,,,,,,)(..)
36
, (,,,,,,,,,,,,)(..)
37
, (,,,,,,,,,,,,,)(..)
38
, (,,,,,,,,,,,,,,)(..)
43
#ifdef __GLASGOW_HASKELL__
46
-- We need to depend on GHC.Base so that
47
-- a) so that we get GHC.Bool, GHC.Classes, GHC.Ordering
49
-- b) so that GHC.Base.inline is available, which is used
50
-- when expanding instance declarations
53
-- We must import GHC.Tuple, to ensure sure that the
54
-- data constructors of `(,)' are in scope when we do
55
-- the standalone deriving instance for Eq (a,b) etc
57
#endif /* __GLASGOW_HASKELL__ */
70
, (,,,,,,,,,)(..)
71
, (,,,,,,,,,,)(..)
72
, (,,,,,,,,,,,)(..)
73
, (,,,,,,,,,,,,)(..)
74
, (,,,,,,,,,,,,,)(..)
75
, (,,,,,,,,,,,,,,)(..)
76
-- nhc98's prelude only supplies tuple instances up to size 15
82
#ifdef __GLASGOW_HASKELL__
86
default () -- Double isn't available yet
88
-- ---------------------------------------------------------------------------
89
-- Standard functions over tuples
91
#if !defined(__HUGS__) && !defined(__NHC__)
92
-- | Extract the first component of a pair.
96
-- | Extract the second component of a pair.
100
-- | 'curry' converts an uncurried function to a curried function.
101
curry :: ((a, b) -> c) -> a -> b -> c
102
curry f x y = f (x, y)
104
-- | 'uncurry' converts a curried function to a function on pairs.
105
uncurry :: (a -> b -> c) -> ((a, b) -> c)
106
uncurry f p = f (fst p) (snd p)
107
#endif /* neither __HUGS__ nor __NHC__ */
109
-- | Swap the components of a pair.
110
swap :: (a,b) -> (b,a)