Repository : ssh://darcs.haskell.org//srv/darcs/packages/haskell2010

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/72baf1ec30a09b7b40dda244cd4dc588790da862

>---------------------------------------------------------------

commit 72baf1ec30a09b7b40dda244cd4dc588790da862
Author: Michal Terepeta <[email protected]>
Date:   Mon Jun 20 21:06:20 2011 +0200

    Make splitAt conform to Haskell 98/2010 (fixes #1182).

>---------------------------------------------------------------

 Data/List.hs |    2 +-
 Prelude.hs   |   23 ++++++++++++++++++++++-
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/Data/List.hs b/Data/List.hs
index 8258663..78f633f 100644
--- a/Data/List.hs
+++ b/Data/List.hs
@@ -181,4 +181,4 @@ module Data.List (
    , genericReplicate  -- :: (Integral a) => a -> b -> [b]
 
   ) where
-import "base" Data.List
+import "base" Data.List hiding ( splitAt )
diff --git a/Prelude.hs b/Prelude.hs
index 9be6ccf..72e53d2 100644
--- a/Prelude.hs
+++ b/Prelude.hs
@@ -137,7 +137,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,24 @@ 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

Reply via email to