X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Data%2FTuple.hs;h=a1495854a5982aa2ae141848a4de544de871bc83;hb=49283ebbb8870082ed2da7f2f564ab890a248e5f;hp=88d2c67fa5202860fb6becec0b8bcff190117a67;hpb=c0bf3d8da1e85d3dcaf94434b9fc46304ec7b39a;p=ghc-base.git diff --git a/Data/Tuple.hs b/Data/Tuple.hs index 88d2c67..a149585 100644 --- a/Data/Tuple.hs +++ b/Data/Tuple.hs @@ -1,4 +1,4 @@ -{-# OPTIONS -fno-implicit-prelude #-} +{-# OPTIONS_GHC -fno-implicit-prelude #-} ----------------------------------------------------------------------------- -- | -- Module : Data.Tuple @@ -13,18 +13,60 @@ -- ----------------------------------------------------------------------------- -module Data.Tuple ( - fst -- :: (a,b) -> a - , snd -- :: (a,b) -> a - , curry -- :: ((a, b) -> c) -> a -> b -> c - , uncurry -- :: (a -> b -> c) -> ((a, b) -> c) - ) where +module Data.Tuple + ( fst -- :: (a,b) -> a + , snd -- :: (a,b) -> a + , curry -- :: ((a, b) -> c) -> a -> b -> c + , uncurry -- :: (a -> b -> c) -> ((a, b) -> c) +#ifdef __NHC__ + , (,)(..) + , (,,)(..) + , (,,,)(..) + , (,,,,)(..) + , (,,,,,)(..) + , (,,,,,,)(..) + , (,,,,,,,)(..) + , (,,,,,,,,)(..) + , (,,,,,,,,,)(..) + , (,,,,,,,,,,)(..) + , (,,,,,,,,,,,)(..) + , (,,,,,,,,,,,,)(..) + , (,,,,,,,,,,,,,)(..) + , (,,,,,,,,,,,,,,)(..) +#endif + ) + where #ifdef __GLASGOW_HASKELL__ import GHC.Base +#endif /* __GLASGOW_HASKELL__ */ + +#ifdef __NHC__ +import Prelude +import Prelude + ( (,)(..) + , (,,)(..) + , (,,,)(..) + , (,,,,)(..) + , (,,,,,)(..) + , (,,,,,,)(..) + , (,,,,,,,)(..) + , (,,,,,,,,)(..) + , (,,,,,,,,,)(..) + , (,,,,,,,,,,)(..) + , (,,,,,,,,,,,)(..) + , (,,,,,,,,,,,,)(..) + , (,,,,,,,,,,,,,)(..) + , (,,,,,,,,,,,,,,)(..) + -- nhc98's prelude only supplies tuple instances up to size 15 + , fst, snd + , curry, uncurry + ) +#endif default () -- Double isn't available yet +#ifdef __GLASGOW_HASKELL__ data (,) a b = (,) a b deriving (Eq, Ord) data (,,) a b c = (,,) a b c deriving (Eq, Ord) data (,,,) a b c d = (,,,) a b c d deriving (Eq, Ord) @@ -215,18 +257,20 @@ data (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -- --------------------------------------------------------------------------- -- Standard functions over tuples -#ifndef __HUGS__ +#if !defined(__HUGS__) && !defined(__NHC__) +-- | Extract the first component of a pair. fst :: (a,b) -> a fst (x,_) = x +-- | Extract the second component of a pair. snd :: (a,b) -> b snd (_,y) = y --- curry converts an uncurried function to a curried function; --- uncurry converts a curried function to a function on pairs. +-- | 'curry' converts an uncurried function to a curried function. curry :: ((a, b) -> c) -> a -> b -> c curry f x y = f (x, y) +-- | 'uncurry' converts a curried function to a function on pairs. uncurry :: (a -> b -> c) -> ((a, b) -> c) uncurry f p = f (fst p) (snd p) -#endif /* __HUGS__ */ +#endif /* neither __HUGS__ nor __NHC__ */