{-# OPTIONS_GHC -XNoImplicitPrelude #-}
+{-# OPTIONS_GHC -fno-warn-unused-imports #-}
+-- XXX -fno-warn-unused-imports needed for the GHC.Tuple import below. Sigh.
-----------------------------------------------------------------------------
-- |
-- Module : Data.Tuple
, snd -- :: (a,b) -> a
, curry -- :: ((a, b) -> c) -> a -> b -> c
, uncurry -- :: (a -> b -> c) -> ((a, b) -> c)
+ , swap -- :: (a,b) -> (b,a)
#ifdef __NHC__
, (,)(..)
, (,,)(..)
where
#ifdef __GLASGOW_HASKELL__
+
import GHC.Base
--- XXX The standalone deriving clauses fail with
--- The data constructors of `(,)' are not all in scope
--- so you cannot derive an instance for it
--- In the stand-alone deriving instance for `Eq (a, b)'
--- if we don't import GHC.Tuple
+-- We need to depend on GHC.Base so that
+-- a) so that we get GHC.Bool, GHC.Classes, GHC.Ordering
+
+-- b) so that GHC.Base.inline is available, which is used
+-- when expanding instance declarations
+
import GHC.Tuple
+-- We must import GHC.Tuple, to ensure sure that the
+-- data constructors of `(,)' are in scope when we do
+-- the standalone deriving instance for Eq (a,b) etc
+
#endif /* __GLASGOW_HASKELL__ */
#ifdef __NHC__
)
#endif
-default () -- Double isn't available yet
-
#ifdef __GLASGOW_HASKELL__
--- XXX Why aren't these derived?
-instance Eq () where
- () == () = True
- () /= () = False
-
-instance Ord () where
- () <= () = True
- () < () = False
- () >= () = True
- () > () = False
- max () () = ()
- min () () = ()
- compare () () = EQ
+import GHC.Unit ()
+#endif
-#ifndef __HADDOCK__
-deriving instance (Eq a, Eq b) => Eq (a, b)
-deriving instance (Ord a, Ord b) => Ord (a, b)
-deriving instance (Eq a, Eq b, Eq c) => Eq (a, b, c)
-deriving instance (Ord a, Ord b, Ord c) => Ord (a, b, c)
-deriving instance (Eq a, Eq b, Eq c, Eq d) => Eq (a, b, c, d)
-deriving instance (Ord a, Ord b, Ord c, Ord d) => Ord (a, b, c, d)
-deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e) => Eq (a, b, c, d, e)
-deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e) => Ord (a, b, c, d, e)
-deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f)
- => Eq (a, b, c, d, e, f)
-deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f)
- => Ord (a, b, c, d, e, f)
-deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g)
- => Eq (a, b, c, d, e, f, g)
-deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g)
- => Ord (a, b, c, d, e, f, g)
-deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
- Eq h)
- => Eq (a, b, c, d, e, f, g, h)
-deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
- Ord h)
- => Ord (a, b, c, d, e, f, g, h)
-deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
- Eq h, Eq i)
- => Eq (a, b, c, d, e, f, g, h, i)
-deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
- Ord h, Ord i)
- => Ord (a, b, c, d, e, f, g, h, i)
-deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
- Eq h, Eq i, Eq j)
- => Eq (a, b, c, d, e, f, g, h, i, j)
-deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
- Ord h, Ord i, Ord j)
- => Ord (a, b, c, d, e, f, g, h, i, j)
-deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
- Eq h, Eq i, Eq j, Eq k)
- => Eq (a, b, c, d, e, f, g, h, i, j, k)
-deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
- Ord h, Ord i, Ord j, Ord k)
- => Ord (a, b, c, d, e, f, g, h, i, j, k)
-deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
- Eq h, Eq i, Eq j, Eq k, Eq l)
- => Eq (a, b, c, d, e, f, g, h, i, j, k, l)
-deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
- Ord h, Ord i, Ord j, Ord k, Ord l)
- => Ord (a, b, c, d, e, f, g, h, i, j, k, l)
-deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
- Eq h, Eq i, Eq j, Eq k, Eq l, Eq m)
- => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m)
-deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
- Ord h, Ord i, Ord j, Ord k, Ord l, Ord m)
- => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m)
-deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
- Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n)
- => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n)
-deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
- Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n)
- => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n)
-deriving instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g,
- Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n, Eq o)
- => Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
-deriving instance (Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g,
- Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n, Ord o)
- => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
-#endif /* !__HADDOCK__ */
-#endif /* __GLASGOW_HASKELL__ */
+default () -- Double isn't available yet
-- ---------------------------------------------------------------------------
-- Standard functions over tuples
uncurry :: (a -> b -> c) -> ((a, b) -> c)
uncurry f p = f (fst p) (snd p)
#endif /* neither __HUGS__ nor __NHC__ */
+
+-- | Swap the components of a pair.
+swap :: (a,b) -> (b,a)
+swap (a,b) = (b,a)