Repository : ssh://darcs.haskell.org//srv/darcs/packages/haskell98 On branch : master
http://hackage.haskell.org/trac/ghc/changeset/2d8b00074746367327134c989de781a794c6072d >--------------------------------------------------------------- commit 2d8b00074746367327134c989de781a794c6072d Author: Michal Terepeta <[email protected]> Date: Mon Jun 20 21:09:01 2011 +0200 Make splitAt conform to Haskell 98/2010 (fixes #1182). >--------------------------------------------------------------- List.hs | 2 +- Prelude.hs | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/List.hs b/List.hs index ca3b51f..147e283 100644 --- a/List.hs +++ b/List.hs @@ -26,4 +26,4 @@ module List ( zip, zip3, zipWith, zipWith3, unzip, unzip3 ) where -import Data.List hiding (foldl') +import Data.List hiding (foldl', splitAt) diff --git a/Prelude.hs b/Prelude.hs index 44342a0..75a35b4 100644 --- a/Prelude.hs +++ b/Prelude.hs @@ -138,7 +138,7 @@ import qualified "base" Control.Exception.Base as New (catch) import "base" Control.Monad import "base" System.IO import "base" System.IO.Error (IOError, ioError, userError) -import "base" Data.List +import "base" Data.List hiding ( splitAt ) import "base" Data.Either import "base" Data.Maybe import "base" Data.Tuple @@ -216,3 +216,25 @@ gcd :: (Integral a) => a -> a -> a gcd 0 0 = error "Prelude.gcd: gcd 0 0 is undefined" gcd x y = GHC.Real.gcd x y #endif + +#ifndef __HUGS__ +-- The GHC's version of 'splitAt' is too strict in 'n' compared to +-- Haskell98/2010 version. Ticket #1182. + +-- | 'splitAt' @n xs@ returns a tuple where first element is @xs@ prefix of +-- length @n@ and second element is the remainder of the list: +-- +-- > splitAt 6 "Hello World!" == ("Hello ","World!") +-- > splitAt 3 [1,2,3,4,5] == ([1,2,3],[4,5]) +-- > splitAt 1 [1,2,3] == ([1],[2,3]) +-- > splitAt 3 [1,2,3] == ([1,2,3],[]) +-- > splitAt 4 [1,2,3] == ([1,2,3],[]) +-- > splitAt 0 [1,2,3] == ([],[1,2,3]) +-- > splitAt (-1) [1,2,3] == ([],[1,2,3]) +-- +-- It is equivalent to @('take' n xs, 'drop' n xs)@. +-- 'splitAt' is an instance of the more general 'Data.List.genericSplitAt', +-- in which @n@ may be of any integral type. +splitAt :: Int -> [a] -> ([a],[a]) +splitAt n xs = (take n xs, drop n xs) +#endif _______________________________________________ Cvs-libraries mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-libraries
