1 {-# OPTIONS_GHC -XNoImplicitPrelude #-}
2 {-# OPTIONS_GHC -fno-warn-unused-imports #-}
3 {-# OPTIONS_GHC -fno-warn-orphans #-}
4 -- XXX -fno-warn-unused-imports needed for the GHC.Tuple import below. Sigh.
5 -----------------------------------------------------------------------------
8 -- Copyright : (c) The University of Glasgow 2001
9 -- License : BSD-style (see the file libraries/base/LICENSE)
11 -- Maintainer : libraries@haskell.org
12 -- Stability : experimental
13 -- Portability : portable
15 -- The tuple data types, and associated functions.
17 -----------------------------------------------------------------------------
20 ( fst -- :: (a,b) -> a
21 , snd -- :: (a,b) -> a
22 , curry -- :: ((a, b) -> c) -> a -> b -> c
23 , uncurry -- :: (a -> b -> c) -> ((a, b) -> c)
33 , (,,,,,,,,,)(..)
34 , (,,,,,,,,,,)(..)
35 , (,,,,,,,,,,,)(..)
36 , (,,,,,,,,,,,,)(..)
37 , (,,,,,,,,,,,,,)(..)
38 , (,,,,,,,,,,,,,,)(..)
43 #ifdef __GLASGOW_HASKELL__
47 -- XXX The standalone deriving clauses fail with
48 -- The data constructors of `(,)' are not all in scope
49 -- so you cannot derive an instance for it
50 -- In the stand-alone deriving instance for `Eq (a, b)'
51 -- if we don't import GHC.Tuple
53 #endif /* __GLASGOW_HASKELL__ */
66 , (,,,,,,,,,)(..)
67 , (,,,,,,,,,,)(..)
68 , (,,,,,,,,,,,)(..)
69 , (,,,,,,,,,,,,)(..)
70 , (,,,,,,,,,,,,,)(..)
71 , (,,,,,,,,,,,,,,)(..)
72 -- nhc98's prelude only supplies tuple instances up to size 15
78 #ifdef __GLASGOW_HASKELL__
82 default () -- Double isn't available yet
84 #ifdef __GLASGOW_HASKELL__
85 -- XXX Why aren't these derived?
100 deriving instance (Eq a, Eq b) => Eq (a, b)
101 deriving instance (Ord a, Ord b) => Ord (a, b)
102 deriving instance (Eq a, Eq b, Eq c) => Eq (a, b, c)
103 deriving instance (Ord a, Ord b, Ord c) => Ord (a, b, c)
104 deriving instance (Eq a, Eq b, Eq c, Eq d) => Eq (a, b, c, d)
105 deriving instance (Ord a, Ord b, Ord c, Ord d) => Ord (a, b, c, d)
106 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e) => Eq (a, b, c, d, e)
107 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e) => Ord (a, b, c, d, e)
108 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f)
109 => Eq (a, b, c, d, e, f)
110 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f)
111 => Ord (a, b, c, d, e, f)
112 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g)
113 => Eq (a, b, c, d, e, f, g)
114 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g)
115 => Ord (a, b, c, d, e, f, g)
116 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
118 => Eq (a, b, c, d, e, f, g, h)
119 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
121 => Ord (a, b, c, d, e, f, g, h)
122 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
124 => Eq (a, b, c, d, e, f, g, h, i)
125 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
127 => Ord (a, b, c, d, e, f, g, h, i)
128 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
130 => Eq (a, b, c, d, e, f, g, h, i, j)
131 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
133 => Ord (a, b, c, d, e, f, g, h, i, j)
134 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
135 Eq h, Eq i, Eq j, Eq k)
136 => Eq (a, b, c, d, e, f, g, h, i, j, k)
137 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
138 Ord h, Ord i, Ord j, Ord k)
139 => Ord (a, b, c, d, e, f, g, h, i, j, k)
140 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
141 Eq h, Eq i, Eq j, Eq k, Eq l)
142 => Eq (a, b, c, d, e, f, g, h, i, j, k, l)
143 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
144 Ord h, Ord i, Ord j, Ord k, Ord l)
145 => Ord (a, b, c, d, e, f, g, h, i, j, k, l)
146 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
147 Eq h, Eq i, Eq j, Eq k, Eq l, Eq m)
148 => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m)
149 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
150 Ord h, Ord i, Ord j, Ord k, Ord l, Ord m)
151 => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m)
152 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
153 Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n)
154 => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n)
155 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
156 Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n)
157 => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n)
158 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
159 Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n, Eq o)
160 => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
161 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
162 Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n, Ord o)
163 => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
164 #endif /* !__HADDOCK__ */
165 #endif /* __GLASGOW_HASKELL__ */
167 -- ---------------------------------------------------------------------------
168 -- Standard functions over tuples
170 #if !defined(__HUGS__) && !defined(__NHC__)
171 -- | Extract the first component of a pair.
175 -- | Extract the second component of a pair.
179 -- | 'curry' converts an uncurried function to a curried function.
180 curry :: ((a, b) -> c) -> a -> b -> c
181 curry f x y = f (x, y)
183 -- | 'uncurry' converts a curried function to a function on pairs.
184 uncurry :: (a -> b -> c) -> ((a, b) -> c)
185 uncurry f p = f (fst p) (snd p)
186 #endif /* neither __HUGS__ nor __NHC__ */