X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Data%2FTuple.hs;h=a5ea87570f88f80c4f79925ae8227f09445d6efb;hb=HEAD;hp=89fb861659bccc580f4357c0abee18b7c1a2b612;hpb=3a6392956bbb1cb908a596bcbb67d7bcc8dbd72f;p=ghc-base.git diff --git a/Data/Tuple.hs b/Data/Tuple.hs index 89fb861..a5ea875 100644 --- a/Data/Tuple.hs +++ b/Data/Tuple.hs @@ -1,4 +1,4 @@ -{-# 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. ----------------------------------------------------------------------------- @@ -20,6 +20,7 @@ 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__ , (,)(..) , (,,)(..) @@ -43,13 +44,13 @@ module Data.Tuple 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 @@ -104,3 +105,7 @@ curry f x y = f (x, y) 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)