@@ -133,8 +133,8 @@ module Data.Text.Lazy
133133
134134 -- ** Breaking into many substrings
135135 -- $split
136+ , splitOn
136137 , split
137− , splitBy
138138 , chunksOf
139139 -- , breakSubstring
140140
@@ -555,7 +555,7 @@ replace :: Text -- ^ Text to search for
555555 -> Text -- ^ Replacement text
556556 -> Text -- ^ Input text
557557 -> Text
558−replace s d = intercalate d . split s
558+replace s d = intercalate d . splitOn s
559559{-# INLINE replace #-}
560560
561561-- ----------------------------------------------------------------------------
@@ -1104,37 +1104,37 @@ tails ts@(Chunk t ts')
11041104--
11051105-- Examples:
11061106--
1107−-- > split "\r\n" "a\r\nb\r\nd\r\ne" == ["a","b","d","e"]
1108−-- > split "aaa" "aaaXaaaXaaaXaaa" == ["","X","X","X",""]
1109−-- > split "x" "x" == ["",""]
1107+-- > splitOn "\r\n" "a\r\nb\r\nd\r\ne" == ["a","b","d","e"]
1108+-- > splitOn "aaa" "aaaXaaaXaaaXaaa" == ["","X","X","X",""]
1109+-- > splitOn "x" "x" == ["",""]
11101110--
11111111-- and
11121112--
1113−-- > intercalate s . split s == id
1114−-- > split (singleton c) == splitBy (==c)
1113+-- > intercalate s . splitOn s == id
1114+-- > splitOn (singleton c) == split (==c)
11151115--
11161116-- This function is strict in its first argument, and lazy in its
11171117-- second.
11181118--
11191119-- In (unlikely) bad cases, this function's time complexity degrades
11201120-- towards /O(n*m)/.
1121−split :: Text -- ^ Text to split on
1122− -> Text -- ^ Input text
1123− -> [Text]
1124−split pat src
1125− | null pat = emptyError "split"
1126− | isSingleton pat = splitBy (== head pat) src
1121+splitOn :: Text -- ^ Text to split on
1122+ -> Text -- ^ Input text
1123+ -> [Text]
1124+splitOn pat src
1125+ | null pat = emptyError "splitOn"
1126+ | isSingleton pat = split (== head pat) src
11271127 | otherwise = go 0 (indices pat src) src
11281128 where
11291129 go _ [] cs = [cs]
11301130 go !i (x:xs) cs = let h :*: t = splitAtWord (x-i) cs
11311131 in h : go (x+l) xs (dropWords l t)
11321132 l = foldlChunks (\a (T.Text _ _ b) -> a + fromIntegral b) 0 pat
1133−{-# INLINE [1] split #-}
1133+{-# INLINE [1] splitOn #-}
11341134
11351135{-# RULES
1136−"LAZY TEXT split/singleton -> splitBy/==" [~1] forall c t.
1137− split (singleton c) t = splitBy (==c) t
1136+"LAZY TEXT splitOn/singleton -> split/==" [~1] forall c t.
1137+ splitOn (singleton c) t = split (==c) t
11381138 #-}
11391139
11401140-- | /O(n)/ Splits a 'Text' into components delimited by separators,
@@ -1142,16 +1142,16 @@ split pat src
11421142-- resulting components do not contain the separators. Two adjacent
11431143-- separators result in an empty component in the output. eg.
11441144--
1145−-- > splitBy (=='a') "aabbaca" == ["","","bb","c",""]
1146−-- > splitBy (=='a') [] == [""]
1147−splitBy :: (Char -> Bool) -> Text -> [Text]
1148−splitBy _ Empty = [Empty]
1149−splitBy p (Chunk t0 ts0) = comb [] (T.splitBy p t0) ts0
1145+-- > split (=='a') "aabbaca" == ["","","bb","c",""]
1146+-- > split (=='a') [] == [""]
1147+split :: (Char -> Bool) -> Text -> [Text]
1148+split _ Empty = [Empty]
1149+split p (Chunk t0 ts0) = comb [] (T.split p t0) ts0
11501150 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
11521152 comb acc (s:ss) ts = revChunks (s:acc) : comb [] ss ts
1153− comb _ [] _ = impossibleError "splitBy"
1154−{-# INLINE splitBy #-}
1153+ comb _ [] _ = impossibleError "split"
1154+{-# INLINE split #-}
11551155
11561156-- | /O(n)/ Splits a 'Text' into components of length @k@. The last
11571157-- element may be shorter than the other chunks, depending on the
@@ -1178,7 +1178,7 @@ lines t = let (l,t') = break ((==) '\n') t
11781178-- | /O(n)/ Breaks a 'Text' up into a list of words, delimited by 'Char's
11791179-- representing white space.
11801180words :: Text -> [Text]
1181−words = L.filter (not . null) . splitBy isSpace
1181+words = L.filter (not . null) . split isSpace
11821182{-# INLINE words #-}
11831183
11841184-- | /O(n)/ Joins lines, after appending a terminating newline to