@@ -117,10 +117,10 @@ module Data.Text
117117 , stripStart
118118 , stripEnd
119119 , splitAt
120− , spanBy
120+ , breakOn
121+ , breakOnEnd
121122 , break
122− , breakEnd
123− , breakBy
123+ , span
124124 , group
125125 , groupBy
126126 , inits
@@ -1009,23 +1009,23 @@ splitAt n t@(Text arr off len)
10091009 where d = iter_ t i
10101010{-# INLINE splitAt #-}
10111011
1012−-- | /O(n)/ 'spanBy', applied to a predicate @p@ and text @t@, returns
1012+-- | /O(n)/ 'span', applied to a predicate @p@ and text @t@, returns
10131013-- a pair whose first element is the longest prefix (possibly empty)
10141014-- of @t@ of elements that satisfy @p@, and whose second is the
10151015-- remainder of the list.
1016−spanBy :: (Char -> Bool) -> Text -> (Text, Text)
1017−spanBy p t@(Text arr off len) = (textP arr off k, textP arr (off+k) (len-k))
1016+span :: (Char -> Bool) -> Text -> (Text, Text)
1017+span p t@(Text arr off len) = (textP arr off k, textP arr (off+k) (len-k))
10181018 where k = loop 0
10191019 loop !i | i >= len || not (p c) = i
10201020 | otherwise = loop (i+d)
10211021 where Iter c d = iter t i
1022−{-# INLINE spanBy #-}
1022+{-# INLINE span #-}
10231023
1024−-- | /O(n)/ 'breakBy' is like 'spanBy', but the prefix returned is
1024+-- | /O(n)/ 'break' is like 'span', but the prefix returned is
10251025-- over elements that fail the predicate @p@.
1026−breakBy :: (Char -> Bool) -> Text -> (Text, Text)
1027−breakBy p = spanBy (not . p)
1028−{-# INLINE breakBy #-}
1026+break :: (Char -> Bool) -> Text -> (Text, Text)
1027+break p = span (not . p)
1028+{-# INLINE break #-}
10291029
10301030-- | /O(n)/ Group characters in a string according to a predicate.
10311031groupBy :: (Char -> Char -> Bool) -> Text -> [Text]
@@ -1113,7 +1113,7 @@ splitBy _ t@(Text _off _arr 0) = [t]
11131113splitBy p t = loop t
11141114 where loop s | null s' = [l]
11151115 | otherwise = l : loop (unsafeTail s')
1116− where (l, s') = breakBy p s
1116+ where (l, s') = break p s
11171117{-# INLINE splitBy #-}
11181118
11191119-- | /O(n)/ Splits a 'Text' into components of length @k@. The last
@@ -1166,13 +1166,13 @@ filter p t = unstream (S.filter p (stream t))
11661166--
11671167-- Examples:
11681168--
1169−-- > break "::" "a::b::c" ==> ("a", "::b::c")
1170−-- > break "/" "foobar" ==> ("foobar", "")
1169+-- > breakOn "::" "a::b::c" ==> ("a", "::b::c")
1170+-- > breakOn "/" "foobar" ==> ("foobar", "")
11711171--
11721172-- Laws:
11731173--
11741174-- > append prefix match == haystack
1175−-- > where (prefix, match) = break needle haystack
1175+-- > where (prefix, match) = breakOn needle haystack
11761176--
11771177-- If you need to break a string by a substring repeatedly (e.g. you
11781178-- want to break on every instance of a substring), use 'find'
@@ -1180,25 +1180,26 @@ filter p t = unstream (S.filter p (stream t))
11801180--
11811181-- In (unlikely) bad cases, this function's time complexity degrades
11821182-- towards /O(n*m)/.
1183−break :: Text -> Text -> (Text, Text)
1184−break pat src@(Text arr off len)
1185− | null pat = emptyError "break"
1183+breakOn :: Text -> Text -> (Text, Text)
1184+breakOn pat src@(Text arr off len)
1185+ | null pat = emptyError "breakOn"
11861186 | otherwise = case indices pat src of
11871187 [] -> (src, empty)
11881188 (x:_) -> (textP arr off x, textP arr (off+x) (len-x))
1189−{-# INLINE break #-}
1189+{-# INLINE breakOn #-}
11901190
1191−-- | /O(n+m)/ Similar to 'break', but searches from the end of the string.
1191+-- | /O(n+m)/ Similar to 'breakOn', but searches from the end of the
1192+-- string.
11921193--
11931194-- The first element of the returned tuple is the prefix of @haystack@
11941195-- up to and including the last match of @needle@. The second is the
11951196-- remainder of @haystack@, following the match.
11961197--
1197−-- > breakEnd "::" "a::b::c" ==> ("a::b::", "c")
1198−breakEnd :: Text -> Text -> (Text, Text)
1199−breakEnd pat src = let (a,b) = break (reverse pat) (reverse src)
1200− in (reverse b, reverse a)
1201−{-# INLINE breakEnd #-}
1198+-- > breakOnEnd "::" "a::b::c" ==> ("a::b::", "c")
1199+breakOnEnd :: Text -> Text -> (Text, Text)
1200+breakOnEnd pat src = (reverse b, reverse a)
1201+ where (a,b) = breakOn (reverse pat) (reverse src)
1202+{-# INLINE breakOnEnd #-}
12021203
12031204-- | /O(n+m)/ Find all non-overlapping instances of @needle@ in
12041205-- @haystack@. Each element of the returned list consists of a pair:
@@ -1325,7 +1326,7 @@ lines ps | null ps = []
13251326 | otherwise = h : if null t
13261327 then []
13271328 else lines (unsafeTail t)
1328− where (h,t) = spanBy (/= '\n') ps
1329+ where (h,t) = span (/= '\n') ps
13291330{-# INLINE lines #-}
13301331
13311332{-