@@ -135,10 +135,10 @@ module Data.Text.Lazy
135135 , stripStart
136136 , stripEnd
137137 , splitAt
138− , spanBy
138+ , span
139+ , breakOn
140+ , breakOnEnd
139141 , break
140− , breakEnd
141− , breakBy
142142 , group
143143 , groupBy
144144 , inits
@@ -146,8 +146,8 @@ module Data.Text.Lazy
146146
147147 -- ** Breaking into many substrings
148148 -- $split
149+ , splitOn
149150 , split
150− , splitBy
151151 , chunksOf
152152 -- , breakSubstring
153153
@@ -169,8 +169,8 @@ module Data.Text.Lazy
169169 -- * Searching
170170 , filter
171171 , find
172− , findBy
173− , partitionBy
172+ , breakOnAll
173+ , partition
174174
175175 -- , findSubstring
176176
@@ -630,7 +630,7 @@ replace :: Text -- ^ Text to search for
630630 -> Text -- ^ Replacement text
631631 -> Text -- ^ Input text
632632 -> Text
633−replace s d = intercalate d . split s
633+replace s d = intercalate d . splitOn s
634634{-# INLINE replace #-}
635635
636636-- ----------------------------------------------------------------------------
@@ -1044,13 +1044,13 @@ splitAtWord x (Chunk c@(T.Text arr off len) cs)
10441044--
10451045-- Examples:
10461046--
1047−-- > break "::" "a::b::c" ==> ("a", "::b::c")
1048−-- > break "/" "foobar" ==> ("foobar", "")
1047+-- > breakOn "::" "a::b::c" ==> ("a", "::b::c")
1048+-- > breakOn "/" "foobar" ==> ("foobar", "")
10491049--
10501050-- Laws:
10511051--
10521052-- > append prefix match == haystack
1053−-- > where (prefix, match) = break needle haystack
1053+-- > where (prefix, match) = breakOn needle haystack
10541054--
10551055-- If you need to break a string by a substring repeatedly (e.g. you
10561056-- want to break on every instance of a substring), use 'find'
@@ -1061,25 +1061,25 @@ splitAtWord x (Chunk c@(T.Text arr off len) cs)
10611061--
10621062-- In (unlikely) bad cases, this function's time complexity degrades
10631063-- towards /O(n*m)/.
1064−break :: Text -> Text -> (Text, Text)
1065−break pat src
1066− | null pat = emptyError "break"
1064+breakOn :: Text -> Text -> (Text, Text)
1065+breakOn pat src
1066+ | null pat = emptyError "breakOn"
10671067 | otherwise = case indices pat src of
10681068 [] -> (src, empty)
10691069 (x:_) -> let h :*: t = splitAtWord x src
10701070 in (h, t)
10711071
1072−-- | /O(n+m)/ Similar to 'break', but searches from the end of the string.
1072+-- | /O(n+m)/ Similar to 'breakOn', but searches from the end of the string.
10731073--
10741074-- The first element of the returned tuple is the prefix of @haystack@
10751075-- up to and including the last match of @needle@. The second is the
10761076-- remainder of @haystack@, following the match.
10771077--
1078−-- > breakEnd "::" "a::b::c" ==> ("a::b::", "c")
1079−breakEnd :: Text -> Text -> (Text, Text)
1080−breakEnd pat src = let (a,b) = break (reverse pat) (reverse src)
1078+-- > breakOnEnd "::" "a::b::c" ==> ("a::b::", "c")
1079+breakOnEnd :: Text -> Text -> (Text, Text)
1080+breakOnEnd pat src = let (a,b) = breakOn (reverse pat) (reverse src)
10811081 in (reverse b, reverse a)
1082−{-# INLINE breakEnd #-}
1082+{-# INLINE breakOnEnd #-}
10831083
10841084-- | /O(n+m)/ Find all non-overlapping instances of @needle@ in
10851085-- @haystack@. Each element of the returned list consists of a pair:
@@ -1090,9 +1090,9 @@ breakEnd pat src = let (a,b) = break (reverse pat) (reverse src)
10901090--
10911091-- Examples:
10921092--
1093−-- > find "::" ""
1093+-- > breakOnAll "::" ""
10941094-- > ==> []
1095−-- > find "/" "a/b/c/"
1095+-- > breakOnAll "/" "a/b/c/"
10961096-- > ==> [("a", "/b/c/"), ("a/b", "/c/"), ("a/b/c", "/")]
10971097--
10981098-- This function is strict in its first argument, and lazy in its
@@ -1102,11 +1102,11 @@ breakEnd pat src = let (a,b) = break (reverse pat) (reverse src)
11021102-- towards /O(n*m)/.
11031103--
11041104-- The @needle@ parameter may not be empty.
1105−find :: Text -- ^ @needle@ to search for
1106− -> Text -- ^ @haystack@ in which to search
1107− -> [(Text, Text)]
1108−find pat src
1109− | null pat = emptyError "find"
1105+breakOnAll :: Text -- ^ @needle@ to search for
1106+ -> Text -- ^ @haystack@ in which to search
1107+ -> [(Text, Text)]
1108+breakOnAll pat src
1109+ | null pat = emptyError "breakOnAll"
11101110 | otherwise = go 0 empty src (indices pat src)
11111111 where
11121112 go !n p s (x:xs) = let h :*: t = splitAtWord (x-n) s
@@ -1114,10 +1114,10 @@ find pat src
11141114 in (h',t) : go x h' t xs
11151115 go _ _ _ _ = []
11161116
1117−-- | /O(n)/ 'breakBy' is like 'spanBy', but the prefix returned is over
1117+-- | /O(n)/ 'break' is like 'span', but the prefix returned is over
11181118-- elements that fail the predicate @p@.
1119−breakBy :: (Char -> Bool) -> Text -> (Text, Text)
1120−breakBy p t0 = break' t0
1119+break :: (Char -> Bool) -> Text -> (Text, Text)
1120+break p t0 = break' t0
11211121 where break' Empty = (empty, empty)
11221122 break' c@(Chunk t ts) =
11231123 case T.findIndex p t of
@@ -1127,13 +1127,13 @@ breakBy p t0 = break' t0
11271127 | otherwise -> let (a,b) = T.splitAt n t
11281128 in (Chunk a Empty, Chunk b ts)
11291129
1130−-- | /O(n)/ 'spanBy', applied to a predicate @p@ and text @t@, returns
1130+-- | /O(n)/ 'span', applied to a predicate @p@ and text @t@, returns
11311131-- a pair whose first element is the longest prefix (possibly empty)
11321132-- of @t@ of elements that satisfy @p@, and whose second is the
11331133-- remainder of the list.
1134−spanBy :: (Char -> Bool) -> Text -> (Text, Text)
1135−spanBy p = breakBy (not . p)
1136−{-# INLINE spanBy #-}
1134+span :: (Char -> Bool) -> Text -> (Text, Text)
1135+span p = break (not . p)
1136+{-# INLINE span #-}
11371137
11381138-- | The 'group' function takes a 'Text' and returns a list of 'Text's
11391139-- such that the concatenation of the result is equal to the argument.
@@ -1152,7 +1152,7 @@ group = groupBy (==)
11521152groupBy :: (Char -> Char -> Bool) -> Text -> [Text]
11531153groupBy _ Empty = []
11541154groupBy eq (Chunk t ts) = cons x ys : groupBy eq zs
1155− where (ys,zs) = spanBy (eq x) xs
1155+ where (ys,zs) = span (eq x) xs
11561156 x = T.unsafeHead t
11571157 xs = chunk (T.unsafeTail t) ts
11581158
@@ -1184,37 +1184,37 @@ tails ts@(Chunk t ts')
11841184--
11851185-- Examples:
11861186--
1187−-- > split "\r\n" "a\r\nb\r\nd\r\ne" == ["a","b","d","e"]
1188−-- > split "aaa" "aaaXaaaXaaaXaaa" == ["","X","X","X",""]
1189−-- > split "x" "x" == ["",""]
1187+-- > splitOn "\r\n" "a\r\nb\r\nd\r\ne" == ["a","b","d","e"]
1188+-- > splitOn "aaa" "aaaXaaaXaaaXaaa" == ["","X","X","X",""]
1189+-- > splitOn "x" "x" == ["",""]
11901190--
11911191-- and
11921192--
1193−-- > intercalate s . split s == id
1194−-- > split (singleton c) == splitBy (==c)
1193+-- > intercalate s . splitOn s == id
1194+-- > splitOn (singleton c) == split (==c)
11951195--
11961196-- This function is strict in its first argument, and lazy in its
11971197-- second.
11981198--
11991199-- In (unlikely) bad cases, this function's time complexity degrades
12001200-- towards /O(n*m)/.
1201−split :: Text -- ^ Text to split on
1202− -> Text -- ^ Input text
1203− -> [Text]
1204−split pat src
1205− | null pat = emptyError "split"
1206− | isSingleton pat = splitBy (== head pat) src
1201+splitOn :: Text -- ^ Text to split on
1202+ -> Text -- ^ Input text
1203+ -> [Text]
1204+splitOn pat src
1205+ | null pat = emptyError "splitOn"
1206+ | isSingleton pat = split (== head pat) src
12071207 | otherwise = go 0 (indices pat src) src
12081208 where
12091209 go _ [] cs = [cs]
12101210 go !i (x:xs) cs = let h :*: t = splitAtWord (x-i) cs
12111211 in h : go (x+l) xs (dropWords l t)
12121212 l = foldlChunks (\a (T.Text _ _ b) -> a + fromIntegral b) 0 pat
1213−{-# INLINE [1] split #-}
1213+{-# INLINE [1] splitOn #-}
12141214
12151215{-# RULES
1216−"LAZY TEXT split/singleton -> splitBy/==" [~1] forall c t.
1217− split (singleton c) t = splitBy (==c) t
1216+"LAZY TEXT splitOn/singleton -> split/==" [~1] forall c t.
1217+ splitOn (singleton c) t = split (==c) t
12181218 #-}
12191219
12201220-- | /O(n)/ Splits a 'Text' into components delimited by separators,
@@ -1222,16 +1222,16 @@ split pat src
12221222-- resulting components do not contain the separators. Two adjacent
12231223-- separators result in an empty component in the output. eg.
12241224--
1225−-- > splitBy (=='a') "aabbaca" == ["","","bb","c",""]
1226−-- > splitBy (=='a') [] == [""]
1227−splitBy :: (Char -> Bool) -> Text -> [Text]
1228−splitBy _ Empty = [Empty]
1229−splitBy p (Chunk t0 ts0) = comb [] (T.splitBy p t0) ts0
1225+-- > split (=='a') "aabbaca" == ["","","bb","c",""]
1226+-- > split (=='a') [] == [""]
1227+split :: (Char -> Bool) -> Text -> [Text]
1228+split _ Empty = [Empty]
1229+split p (Chunk t0 ts0) = comb [] (T.split p t0) ts0
12301230 where comb acc (s:[]) Empty = revChunks (s:acc) : []
1231− comb acc (s:[]) (Chunk t ts) = comb (s:acc) (T.splitBy p t) ts
1231+ comb acc (s:[]) (Chunk t ts) = comb (s:acc) (T.split p t) ts
12321232 comb acc (s:ss) ts = revChunks (s:acc) : comb [] ss ts
1233− comb _ [] _ = impossibleError "splitBy"
1234−{-# INLINE splitBy #-}
1233+ comb _ [] _ = impossibleError "split"
1234+{-# INLINE split #-}
12351235
12361236-- | /O(n)/ Splits a 'Text' into components of length @k@. The last
12371237-- element may be shorter than the other chunks, depending on the
@@ -1251,14 +1251,14 @@ chunksOf k = go
12511251-- newline 'Char's. The resulting strings do not contain newlines.
12521252lines :: Text -> [Text]
12531253lines Empty = []
1254−lines t = let (l,t') = breakBy ((==) '\n') t
1254+lines t = let (l,t') = break ((==) '\n') t
12551255 in l : if null t' then []
12561256 else lines (tail t')
12571257
12581258-- | /O(n)/ Breaks a 'Text' up into a list of words, delimited by 'Char's
12591259-- representing white space.
12601260words :: Text -> [Text]
1261−words = L.filter (not . null) . splitBy isSpace
1261+words = L.filter (not . null) . split isSpace
12621262{-# INLINE words #-}
12631263
12641264-- | /O(n)/ Joins lines, after appending a terminating newline to
@@ -1378,21 +1378,21 @@ filter :: (Char -> Bool) -> Text -> Text
13781378filter p t = unstream (S.filter p (stream t))
13791379{-# INLINE filter #-}
13801380
1381−-- | /O(n)/ The 'findBy' function takes a predicate and a 'Text', and
1381+-- | /O(n)/ The 'find' function takes a predicate and a 'Text', and
13821382-- returns the first element in matching the predicate, or 'Nothing'
13831383-- if there is no such element.
1384−findBy :: (Char -> Bool) -> Text -> Maybe Char
1385−findBy p t = S.findBy p (stream t)
1386−{-# INLINE findBy #-}
1384+find :: (Char -> Bool) -> Text -> Maybe Char
1385+find p t = S.findBy p (stream t)
1386+{-# INLINE find #-}
13871387
1388−-- | /O(n)/ The 'partitionBy' function takes a predicate and a 'Text',
1388+-- | /O(n)/ The 'partition' function takes a predicate and a 'Text',
13891389-- and returns the pair of 'Text's with elements which do and do not
13901390-- satisfy the predicate, respectively; i.e.
13911391--
1392−-- > partitionBy p t == (filter p t, filter (not . p) t)
1393−partitionBy :: (Char -> Bool) -> Text -> (Text, Text)
1394−partitionBy p t = (filter p t, filter (not . p) t)
1395−{-# INLINE partitionBy #-}
1392+-- > partition p t == (filter p t, filter (not . p) t)
1393+partition :: (Char -> Bool) -> Text -> (Text, Text)
1394+partition p t = (filter p t, filter (not . p) t)
1395+{-# INLINE partition #-}
13961396
13971397-- | /O(n)/ 'Text' index (subscript) operator, starting from 0.
13981398index :: Text -> Int64 -> Char