@@ -133,8 +133,8 @@ module Data.Text.Lazy
134 -- ** Breaking into many substrings
134 -- ** Breaking into many substrings
135 -- $split
135 -- $split
138 , chunksOf
138 , chunksOf
139 -- , breakSubstring
139 -- , breakSubstring
@@ -555,7 +555,7 @@ replace :: Text -- ^ Text to search for
555 -> Text -- ^ Replacement text
555 -> Text -- ^ Replacement text
556 -> Text -- ^ Input text
556 -> Text -- ^ Input text
558−replace s d = intercalate d . split s
558+replace s d = intercalate d . splitOn s
559{-# INLINE replace #-}
559{-# INLINE replace #-}
561-- ----------------------------------------------------------------------------
561-- ----------------------------------------------------------------------------
@@ -1104,37 +1104,37 @@ tails ts@(Chunk t ts')
1105-- Examples:
1105-- Examples:
1107−-- > split "\r\n" "a\r\nb\r\nd\r\ne" == ["a","b","d","e"]
1107+-- > splitOn "\r\n" "a\r\nb\r\nd\r\ne" == ["a","b","d","e"]
1108−-- > split "aaa" "aaaXaaaXaaaXaaa" == ["","X","X","X",""]
1108+-- > splitOn "aaa" "aaaXaaaXaaaXaaa" == ["","X","X","X",""]
1109−-- > split "x" "x" == ["",""]
1109+-- > splitOn "x" "x" == ["",""]
1113−-- > intercalate s . split s == id
1113+-- > intercalate s . splitOn s == id
1114−-- > split (singleton c) == splitBy (==c)
1114+-- > splitOn (singleton c) == split (==c)
1116-- This function is strict in its first argument, and lazy in its
1116-- This function is strict in its first argument, and lazy in its
1117-- second.
1117-- second.
1119-- In (unlikely) bad cases, this function's time complexity degrades
1119-- In (unlikely) bad cases, this function's time complexity degrades
1120-- towards /O(n*m)/.
1120-- towards /O(n*m)/.
1121−split :: Text -- ^ Text to split on
1121+splitOn :: Text -- ^ Text to split on
1122− -> Text -- ^ Input text
1122+ -> Text -- ^ Input text
1123− -> [Text]
1123+ -> [Text]
1124−split pat src
1124+splitOn pat src
1125− | null pat = emptyError "split"
1125+ | null pat = emptyError "splitOn"
1126− | isSingleton pat = splitBy (== head pat) src
1126+ | isSingleton pat = split (== head pat) src
1127 | otherwise = go 0 (indices pat src) src
1127 | otherwise = go 0 (indices pat src) src
1129 go _ [] cs = [cs]
1129 go _ [] cs = [cs]
1130 go !i (x:xs) cs = let h :*: t = splitAtWord (x-i) cs
1130 go !i (x:xs) cs = let h :*: t = splitAtWord (x-i) cs
1131 in h : go (x+l) xs (dropWords l t)
1131 in h : go (x+l) xs (dropWords l t)
1132 l = foldlChunks (\a (T.Text _ _ b) -> a + fromIntegral b) 0 pat
1132 l = foldlChunks (\a (T.Text _ _ b) -> a + fromIntegral b) 0 pat
1133−{-# INLINE [1] split #-}
1133+{-# INLINE [1] splitOn #-}
1135{-# RULES
1135{-# RULES
1136−"LAZY TEXT split/singleton -> splitBy/==" [~1] forall c t.
1136+"LAZY TEXT splitOn/singleton -> split/==" [~1] forall c t.
1137− split (singleton c) t = splitBy (==c) t
1137+ splitOn (singleton c) t = split (==c) t
1140-- | /O(n)/ Splits a 'Text' into components delimited by separators,
1140-- | /O(n)/ Splits a 'Text' into components delimited by separators,
@@ -1142,16 +1142,16 @@ split pat src
1142-- resulting components do not contain the separators. Two adjacent
1142-- resulting components do not contain the separators. Two adjacent
1143-- separators result in an empty component in the output. eg.
1143-- separators result in an empty component in the output. eg.
1145−-- > splitBy (=='a') "aabbaca" == ["","","bb","c",""]
1145+-- > split (=='a') "aabbaca" == ["","","bb","c",""]
1146−-- > splitBy (=='a') [] == [""]
1146+-- > split (=='a') [] == [""]
1147−splitBy :: (Char -> Bool) -> Text -> [Text]
1147+split :: (Char -> Bool) -> Text -> [Text]
1148−splitBy _ Empty = [Empty]
1148+split _ Empty = [Empty]
1149−splitBy p (Chunk t0 ts0) = comb [] (T.splitBy p t0) ts0
1149+split p (Chunk t0 ts0) = comb [] (T.split p t0) ts0
1150 where comb acc (s:[]) Empty = revChunks (s:acc) : []
1150 where comb acc (s:[]) Empty = revChunks (s:acc) : []
1151− comb acc (s:[]) (Chunk t ts) = comb (s:acc) (T.splitBy p t) ts
1151+ comb acc (s:[]) (Chunk t ts) = comb (s:acc) (T.split p t) ts
1152 comb acc (s:ss) ts = revChunks (s:acc) : comb [] ss ts
1152 comb acc (s:ss) ts = revChunks (s:acc) : comb [] ss ts
1153− comb _ [] _ = impossibleError "splitBy"
1153+ comb _ [] _ = impossibleError "split"
1154−{-# INLINE splitBy #-}
1154+{-# INLINE split #-}
1156-- | /O(n)/ Splits a 'Text' into components of length @k@. The last
1156-- | /O(n)/ Splits a 'Text' into components of length @k@. The last
1157-- element may be shorter than the other chunks, depending on the
1157-- element may be shorter than the other chunks, depending on the
@@ -1178,7 +1178,7 @@ lines t = let (l,t') = break ((==) '\n') t
1178-- | /O(n)/ Breaks a 'Text' up into a list of words, delimited by 'Char's
1178-- | /O(n)/ Breaks a 'Text' up into a list of words, delimited by 'Char's
1179-- representing white space.
1179-- representing white space.
1180words :: Text -> [Text]
1180words :: Text -> [Text]
1181−words = L.filter (not . null) . splitBy isSpace
1181+words = L.filter (not . null) . split isSpace
1182{-# INLINE words #-}
1182{-# INLINE words #-}
1184-- | /O(n)/ Joins lines, after appending a terminating newline to
1184-- | /O(n)/ Joins lines, after appending a terminating newline to