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 default () -- Double isn't available yet
80 #ifdef __GLASGOW_HASKELL__
81 -- XXX Why aren't these derived?
96 deriving instance (Eq a, Eq b) => Eq (a, b)
97 deriving instance (Ord a, Ord b) => Ord (a, b)
98 deriving instance (Eq a, Eq b, Eq c) => Eq (a, b, c)
99 deriving instance (Ord a, Ord b, Ord c) => Ord (a, b, c)
100 deriving instance (Eq a, Eq b, Eq c, Eq d) => Eq (a, b, c, d)
101 deriving instance (Ord a, Ord b, Ord c, Ord d) => Ord (a, b, c, d)
102 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e) => Eq (a, b, c, d, e)
103 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e) => Ord (a, b, c, d, e)
104 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f)
105 => Eq (a, b, c, d, e, f)
106 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f)
107 => Ord (a, b, c, d, e, f)
108 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g)
109 => Eq (a, b, c, d, e, f, g)
110 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g)
111 => Ord (a, b, c, d, e, f, g)
112 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
114 => Eq (a, b, c, d, e, f, g, h)
115 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
117 => Ord (a, b, c, d, e, f, g, h)
118 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
120 => Eq (a, b, c, d, e, f, g, h, i)
121 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
123 => Ord (a, b, c, d, e, f, g, h, i)
124 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
126 => Eq (a, b, c, d, e, f, g, h, i, j)
127 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
129 => Ord (a, b, c, d, e, f, g, h, i, j)
130 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
131 Eq h, Eq i, Eq j, Eq k)
132 => Eq (a, b, c, d, e, f, g, h, i, j, k)
133 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
134 Ord h, Ord i, Ord j, Ord k)
135 => Ord (a, b, c, d, e, f, g, h, i, j, k)
136 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
137 Eq h, Eq i, Eq j, Eq k, Eq l)
138 => Eq (a, b, c, d, e, f, g, h, i, j, k, l)
139 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
140 Ord h, Ord i, Ord j, Ord k, Ord l)
141 => Ord (a, b, c, d, e, f, g, h, i, j, k, l)
142 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
143 Eq h, Eq i, Eq j, Eq k, Eq l, Eq m)
144 => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m)
145 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
146 Ord h, Ord i, Ord j, Ord k, Ord l, Ord m)
147 => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m)
148 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
149 Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n)
150 => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n)
151 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
152 Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n)
153 => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n)
154 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
155 Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n, Eq o)
156 => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
157 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
158 Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n, Ord o)
159 => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
160 #endif /* !__HADDOCK__ */
161 #endif /* __GLASGOW_HASKELL__ */
163 -- ---------------------------------------------------------------------------
164 -- Standard functions over tuples
166 #if !defined(__HUGS__) && !defined(__NHC__)
167 -- | Extract the first component of a pair.
171 -- | Extract the second component of a pair.
175 -- | 'curry' converts an uncurried function to a curried function.
176 curry :: ((a, b) -> c) -> a -> b -> c
177 curry f x y = f (x, y)
179 -- | 'uncurry' converts a curried function to a function on pairs.
180 uncurry :: (a -> b -> c) -> ((a, b) -> c)
181 uncurry f p = f (fst p) (snd p)
182 #endif /* neither __HUGS__ nor __NHC__ */