Hide standalone deriving clauses from haddock
[ghc-base.git] / Data / Tuple.hs
1 {-# OPTIONS_GHC -XNoImplicitPrelude #-}
2 -----------------------------------------------------------------------------
3 -- |
4 -- Module      :  Data.Tuple
5 -- Copyright   :  (c) The University of Glasgow 2001
6 -- License     :  BSD-style (see the file libraries/base/LICENSE)
7 -- 
8 -- Maintainer  :  libraries@haskell.org
9 -- Stability   :  experimental
10 -- Portability :  portable
11 --
12 -- The tuple data types, and associated functions.
13 --
14 -----------------------------------------------------------------------------
15
16 module Data.Tuple
17   ( fst         -- :: (a,b) -> a
18   , snd         -- :: (a,b) -> a
19   , curry       -- :: ((a, b) -> c) -> a -> b -> c
20   , uncurry     -- :: (a -> b -> c) -> ((a, b) -> c)
21 #ifdef __NHC__
22   , (,)(..)
23   , (,,)(..)
24   , (,,,)(..)
25   , (,,,,)(..)
26   , (,,,,,)(..)
27   , (,,,,,,)(..)
28   , (,,,,,,,)(..)
29   , (,,,,,,,,)(..)
30   , (,,,,,,,,,)(..)
31   , (,,,,,,,,,,)(..)
32   , (,,,,,,,,,,,)(..)
33   , (,,,,,,,,,,,,)(..)
34   , (,,,,,,,,,,,,,)(..)
35   , (,,,,,,,,,,,,,,)(..)
36 #endif
37   )
38     where
39
40 #ifdef __GLASGOW_HASKELL__
41 import GHC.Base
42 -- XXX The standalone deriving clauses fail with
43 --     The data constructors of `(,)' are not all in scope
44 --       so you cannot derive an instance for it
45 --     In the stand-alone deriving instance for `Eq (a, b)'
46 -- if we don't import GHC.Tuple
47 import GHC.Tuple
48 #endif  /* __GLASGOW_HASKELL__ */
49
50 #ifdef __NHC__
51 import Prelude
52 import Prelude
53   ( (,)(..)
54   , (,,)(..)
55   , (,,,)(..)
56   , (,,,,)(..)
57   , (,,,,,)(..)
58   , (,,,,,,)(..)
59   , (,,,,,,,)(..)
60   , (,,,,,,,,)(..)
61   , (,,,,,,,,,)(..)
62   , (,,,,,,,,,,)(..)
63   , (,,,,,,,,,,,)(..)
64   , (,,,,,,,,,,,,)(..)
65   , (,,,,,,,,,,,,,)(..)
66   , (,,,,,,,,,,,,,,)(..)
67   -- nhc98's prelude only supplies tuple instances up to size 15
68   , fst, snd
69   , curry, uncurry
70   )
71 #endif
72
73 default ()              -- Double isn't available yet
74
75 #ifdef __GLASGOW_HASKELL__
76 -- XXX Why aren't these derived?
77 instance Eq () where
78     () == () = True
79     () /= () = False
80
81 instance Ord () where
82     () <= () = True
83     () <  () = False
84     () >= () = True
85     () >  () = False
86     max () () = ()
87     min () () = ()
88     compare () () = EQ
89
90 #ifndef __HADDOCK__
91 deriving instance (Eq  a, Eq  b) => Eq  (a, b)
92 deriving instance (Ord a, Ord b) => Ord (a, b)
93 deriving instance (Eq  a, Eq  b, Eq  c) => Eq  (a, b, c)
94 deriving instance (Ord a, Ord b, Ord c) => Ord (a, b, c)
95 deriving instance (Eq  a, Eq  b, Eq  c, Eq  d) => Eq  (a, b, c, d)
96 deriving instance (Ord a, Ord b, Ord c, Ord d) => Ord (a, b, c, d)
97 deriving instance (Eq  a, Eq  b, Eq  c, Eq  d, Eq  e) => Eq  (a, b, c, d, e)
98 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e) => Ord (a, b, c, d, e)
99 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f)
100                => Eq (a, b, c, d, e, f)
101 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f)
102                => Ord (a, b, c, d, e, f)
103 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g)
104                => Eq (a, b, c, d, e, f, g)
105 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g)
106                => Ord (a, b, c, d, e, f, g)
107 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
108                    Eq h)
109                => Eq (a, b, c, d, e, f, g, h)
110 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
111                    Ord h)
112                => Ord (a, b, c, d, e, f, g, h)
113 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
114                    Eq h, Eq i)
115                => Eq (a, b, c, d, e, f, g, h, i)
116 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
117                    Ord h, Ord i)
118                => Ord (a, b, c, d, e, f, g, h, i)
119 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
120                    Eq h, Eq i, Eq j)
121                => Eq (a, b, c, d, e, f, g, h, i, j)
122 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
123                    Ord h, Ord i, Ord j)
124                => Ord (a, b, c, d, e, f, g, h, i, j)
125 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
126                    Eq h, Eq i, Eq j, Eq k)
127                => Eq (a, b, c, d, e, f, g, h, i, j, k)
128 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
129                    Ord h, Ord i, Ord j, Ord k)
130                => Ord (a, b, c, d, e, f, g, h, i, j, k)
131 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
132                    Eq h, Eq i, Eq j, Eq k, Eq l)
133                => Eq (a, b, c, d, e, f, g, h, i, j, k, l)
134 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
135                    Ord h, Ord i, Ord j, Ord k, Ord l)
136                => Ord (a, b, c, d, e, f, g, h, i, j, k, l)
137 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
138                    Eq h, Eq i, Eq j, Eq k, Eq l, Eq m)
139                => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m)
140 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
141                    Ord h, Ord i, Ord j, Ord k, Ord l, Ord m)
142                => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m)
143 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
144                    Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n)
145                => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n)
146 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
147                    Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n)
148                => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n)
149 deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
150                    Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n, Eq o)
151                => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
152 deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
153                    Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n, Ord o)
154                => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
155 #endif  /* !__HADDOCK__ */
156 #endif  /* __GLASGOW_HASKELL__ */
157
158 -- ---------------------------------------------------------------------------
159 -- Standard functions over tuples
160
161 #if !defined(__HUGS__) && !defined(__NHC__)
162 -- | Extract the first component of a pair.
163 fst                     :: (a,b) -> a
164 fst (x,_)               =  x
165
166 -- | Extract the second component of a pair.
167 snd                     :: (a,b) -> b
168 snd (_,y)               =  y
169
170 -- | 'curry' converts an uncurried function to a curried function.
171 curry                   :: ((a, b) -> c) -> a -> b -> c
172 curry f x y             =  f (x, y)
173
174 -- | 'uncurry' converts a curried function to a function on pairs.
175 uncurry                 :: (a -> b -> c) -> ((a, b) -> c)
176 uncurry f p             =  f (fst p) (snd p)
177 #endif  /* neither __HUGS__ nor __NHC__ */