-{-# OPTIONS_GHC -XNoImplicitPrelude #-}
+{-# LANGUAGE CPP, NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- XXX -fno-warn-unused-imports needed for the GHC.Tuple import below. Sigh.
-----------------------------------------------------------------------------
, 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__
, (,)(..)
, (,,)(..)
import GHC.Base
-- We need to depend on GHC.Base so that
--- a) so that we get GHC.Bool, GHC.Classes, GHC.Ordering
+-- a) so that we get GHC.Classes, GHC.Ordering, GHC.Types
-- 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
+-- 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
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)