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__
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 #ifdef __GLASGOW_HASKELL__
89 -- XXX Why aren't these derived?
104 deriving instance (Eq a, Eq b) => Eq (a, b)
105 deriving instance (Ord a, Ord b) => Ord (a, b)
106 deriving instance (Eq a, Eq b, Eq c) => Eq (a, b, c)
107 deriving instance (Ord a, Ord b, Ord c) => Ord (a, b, c)
108 deriving instance (Eq a, Eq b, Eq c, Eq d) => Eq (a, b, c, d)
109 deriving instance (Ord a, Ord b, Ord c, Ord d) => Ord (a, b, c, d)
110 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e) => Eq (a, b, c, d, e)
111 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e) => Ord (a, b, c, d, e)
112 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f)
113 => Eq (a, b, c, d, e, f)
114 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f)
115 => Ord (a, b, c, d, e, f)
116 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g)
117 => Eq (a, b, c, d, e, f, g)
118 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g)
119 => Ord (a, b, c, d, e, f, g)
120 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
122 => Eq (a, b, c, d, e, f, g, h)
123 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
125 => Ord (a, b, c, d, e, f, g, h)
126 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
128 => Eq (a, b, c, d, e, f, g, h, i)
129 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
131 => Ord (a, b, c, d, e, f, g, h, i)
132 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
134 => Eq (a, b, c, d, e, f, g, h, i, j)
135 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
137 => Ord (a, b, c, d, e, f, g, h, i, j)
138 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
139 Eq h, Eq i, Eq j, Eq k)
140 => Eq (a, b, c, d, e, f, g, h, i, j, k)
141 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
142 Ord h, Ord i, Ord j, Ord k)
143 => Ord (a, b, c, d, e, f, g, h, i, j, k)
144 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
145 Eq h, Eq i, Eq j, Eq k, Eq l)
146 => Eq (a, b, c, d, e, f, g, h, i, j, k, l)
147 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
148 Ord h, Ord i, Ord j, Ord k, Ord l)
149 => Ord (a, b, c, d, e, f, g, h, i, j, k, l)
150 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
151 Eq h, Eq i, Eq j, Eq k, Eq l, Eq m)
152 => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m)
153 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
154 Ord h, Ord i, Ord j, Ord k, Ord l, Ord m)
155 => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m)
156 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
157 Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n)
158 => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n)
159 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
160 Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n)
161 => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n)
162 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
163 Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n, Eq o)
164 => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
165 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
166 Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n, Ord o)
167 => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
168 #endif /* !__HADDOCK__ */
169 #endif /* __GLASGOW_HASKELL__ */
171 -- ---------------------------------------------------------------------------
172 -- Standard functions over tuples
174 #if !defined(__HUGS__) && !defined(__NHC__)
175 -- | Extract the first component of a pair.
179 -- | Extract the second component of a pair.
183 -- | 'curry' converts an uncurried function to a curried function.
184 curry :: ((a, b) -> c) -> a -> b -> c
185 curry f x y = f (x, y)
187 -- | 'uncurry' converts a curried function to a function on pairs.
188 uncurry :: (a -> b -> c) -> ((a, b) -> c)
189 uncurry f p = f (fst p) (snd p)
190 #endif /* neither __HUGS__ nor __NHC__ */