on master help sign in
Fix type of splitAt

--HG-- extra : convert_revision : c9ae2e42fa59ea9b9e03cb58838928b3344baea2

commit919bf33be92e870e8a48505da492882f3a7e4f8a authorBryan O'Sullivan <bos@serpentine.com> dateWed 4 Mar 2009, 05:40 (18 years ago) parentb15c35e
2 files changed+4−4
Data/Text/Lazy.hs+2−2 tests/Properties.hs+2−2
Data/Text/Lazy.hs+2−2
@@ -577,12 +577,12 @@ dropWhile p t0 = dropWhile' t0
577577-- | /O(n)/ 'splitAt' @n t@ returns a pair whose first element is a
578578-- prefix of @t@ of length @n@, and whose second is the remainder of
579579-- the string. It is equivalent to @('take' n t, 'drop' n t)@.
580−splitAt :: Int -> Text -> (Text, Text)
580+splitAt :: Int64 -> Text -> (Text, Text)
581581splitAt = loop
582582 where loop _ Empty = (empty, empty)
583583 loop n t | n <= 0 = (empty, t)
584584 loop n (Chunk t ts)
585− | n < len = let (ts',ts'') = T.splitAt n t
585+ | n < len = let (ts',ts'') = T.splitAt (fromIntegral n) t
586586 in (Chunk ts' Empty, Chunk ts'' Empty)
587587 | otherwise = let (ts',ts'') = loop (n - len) ts
588588 in (Chunk t ts', ts'')
tests/Properties.hs+2−2
@@ -69,7 +69,7 @@ instance Target T.Text where
6969instance Target TL.Text where
7070 packT = TL.pack
7171 unpackT = TL.unpack
72− splitAtT = TL.splitAt
72+ splitAtT = TL.splitAt . fromIntegral
7373
7474-- Do two functions give the same answer?
7575eq :: (Eq a) => (t -> a) -> (t -> a) -> t -> Bool
@@ -228,7 +228,7 @@ prop_S_dropWhile p = L.dropWhile p `eqP` (unpackT . S.dropWhile p)
228228prop_T_dropWhile p = L.dropWhile p `eqP` (unpackT . T.dropWhile p)
229229prop_TL_dropWhile p = L.dropWhile p `eqP` (unpackT . S.dropWhile p)
230230prop_T_splitAt n = L.splitAt n `eqP` (unpack2 . T.splitAt n)
231−prop_TL_splitAt n = L.splitAt n `eqP` (unpack2 . TL.splitAt n)
231+prop_TL_splitAt n = L.splitAt n `eqP` (unpack2 . TL.splitAt (fromIntegral n))
232232prop_T_span p = L.span p `eqP` (unpack2 . T.span p)
233233prop_T_break p = L.break p `eqP` (unpack2 . T.break p)
234234prop_T_group = L.group `eqP` (map unpackT . T.group)