@@ -122,10 +122,10 @@ module Data.Text.Lazy
122 , stripStart
122 , stripStart
123 , stripEnd
123 , stripEnd
124 , splitAt
124 , splitAt
130 , groupBy
130 , groupBy
@@ -964,13 +964,13 @@ splitAtWord x (Chunk c@(T.Text arr off len) cs)
965-- Examples:
965-- Examples:
967−-- > break "::" "a::b::c" ==> ("a", "::b::c")
967+-- > breakOn "::" "a::b::c" ==> ("a", "::b::c")
968−-- > break "/" "foobar" ==> ("foobar", "")
968+-- > breakOn "/" "foobar" ==> ("foobar", "")
972-- > append prefix match == haystack
972-- > append prefix match == haystack
973−-- > where (prefix, match) = break needle haystack
973+-- > where (prefix, match) = breakOn needle haystack
975-- If you need to break a string by a substring repeatedly (e.g. you
975-- If you need to break a string by a substring repeatedly (e.g. you
976-- want to break on every instance of a substring), use 'find'
976-- want to break on every instance of a substring), use 'find'
@@ -981,25 +981,25 @@ splitAtWord x (Chunk c@(T.Text arr off len) cs)
982-- In (unlikely) bad cases, this function's time complexity degrades
982-- In (unlikely) bad cases, this function's time complexity degrades
983-- towards /O(n*m)/.
983-- towards /O(n*m)/.
984−break :: Text -> Text -> (Text, Text)
984+breakOn :: Text -> Text -> (Text, Text)
985−break pat src
985+breakOn pat src
986− | null pat = emptyError "break"
986+ | null pat = emptyError "breakOn"
987 | otherwise = case indices pat src of
987 | otherwise = case indices pat src of
988 [] -> (src, empty)
988 [] -> (src, empty)
989 (x:_) -> let h :*: t = splitAtWord x src
989 (x:_) -> let h :*: t = splitAtWord x src
990 in (h, t)
990 in (h, t)
992−-- | /O(n+m)/ Similar to 'break', but searches from the end of the string.
992+-- | /O(n+m)/ Similar to 'breakOn', but searches from the end of the string.
994-- The first element of the returned tuple is the prefix of @haystack@
994-- The first element of the returned tuple is the prefix of @haystack@
995-- up to and including the last match of @needle@. The second is the
995-- up to and including the last match of @needle@. The second is the
996-- remainder of @haystack@, following the match.
996-- remainder of @haystack@, following the match.
998−-- > breakEnd "::" "a::b::c" ==> ("a::b::", "c")
998+-- > breakOnEnd "::" "a::b::c" ==> ("a::b::", "c")
999−breakEnd :: Text -> Text -> (Text, Text)
999+breakOnEnd :: Text -> Text -> (Text, Text)
1000−breakEnd pat src = let (a,b) = break (reverse pat) (reverse src)
1000+breakOnEnd pat src = let (a,b) = breakOn (reverse pat) (reverse src)
1001 in (reverse b, reverse a)
1001 in (reverse b, reverse a)
1002−{-# INLINE breakEnd #-}
1002+{-# INLINE breakOnEnd #-}
1004-- | /O(n+m)/ Find all non-overlapping instances of @needle@ in
1004-- | /O(n+m)/ Find all non-overlapping instances of @needle@ in
1005-- @haystack@. Each element of the returned list consists of a pair:
1005-- @haystack@. Each element of the returned list consists of a pair:
@@ -1034,10 +1034,10 @@ find pat src
1034 in (h',t) : go x h' t xs
1034 in (h',t) : go x h' t xs
1035 go _ _ _ _ = []
1035 go _ _ _ _ = []
1037−-- | /O(n)/ 'breakBy' is like 'spanBy', but the prefix returned is over
1037+-- | /O(n)/ 'break' is like 'span', but the prefix returned is over
1038-- elements that fail the predicate @p@.
1038-- elements that fail the predicate @p@.
1039−breakBy :: (Char -> Bool) -> Text -> (Text, Text)
1039+break :: (Char -> Bool) -> Text -> (Text, Text)
1040−breakBy p t0 = break' t0
1040+break p t0 = break' t0
1041 where break' Empty = (empty, empty)
1041 where break' Empty = (empty, empty)
1042 break' c@(Chunk t ts) =
1042 break' c@(Chunk t ts) =
1043 case T.findIndex p t of
1043 case T.findIndex p t of
@@ -1047,13 +1047,13 @@ breakBy p t0 = break' t0
1047 | otherwise -> let (a,b) = T.splitAt n t
1047 | otherwise -> let (a,b) = T.splitAt n t
1048 in (Chunk a Empty, Chunk b ts)
1048 in (Chunk a Empty, Chunk b ts)
1050−-- | /O(n)/ 'spanBy', applied to a predicate @p@ and text @t@, returns
1050+-- | /O(n)/ 'span', applied to a predicate @p@ and text @t@, returns
1051-- a pair whose first element is the longest prefix (possibly empty)
1051-- a pair whose first element is the longest prefix (possibly empty)
1052-- of @t@ of elements that satisfy @p@, and whose second is the
1052-- of @t@ of elements that satisfy @p@, and whose second is the
1053-- remainder of the list.
1053-- remainder of the list.
1054−spanBy :: (Char -> Bool) -> Text -> (Text, Text)
1054+span :: (Char -> Bool) -> Text -> (Text, Text)
1055−spanBy p = breakBy (not . p)
1055+span p = break (not . p)
1056−{-# INLINE spanBy #-}
1056+{-# INLINE span #-}
1058-- | The 'group' function takes a 'Text' and returns a list of 'Text's
1058-- | The 'group' function takes a 'Text' and returns a list of 'Text's
1059-- such that the concatenation of the result is equal to the argument.
1059-- such that the concatenation of the result is equal to the argument.
@@ -1072,7 +1072,7 @@ group = groupBy (==)
1072groupBy :: (Char -> Char -> Bool) -> Text -> [Text]
1072groupBy :: (Char -> Char -> Bool) -> Text -> [Text]
1073groupBy _ Empty = []
1073groupBy _ Empty = []
1074groupBy eq (Chunk t ts) = cons x ys : groupBy eq zs
1074groupBy eq (Chunk t ts) = cons x ys : groupBy eq zs
1075− where (ys,zs) = spanBy (eq x) xs
1075+ where (ys,zs) = span (eq x) xs
1076 x = T.unsafeHead t
1076 x = T.unsafeHead t
1077 xs = chunk (T.unsafeTail t) ts
1077 xs = chunk (T.unsafeTail t) ts
@@ -1171,7 +1171,7 @@ chunksOf k = go
1171-- newline 'Char's. The resulting strings do not contain newlines.
1171-- newline 'Char's. The resulting strings do not contain newlines.
1172lines :: Text -> [Text]
1172lines :: Text -> [Text]
1173lines Empty = []
1173lines Empty = []
1174−lines t = let (l,t') = breakBy ((==) '\n') t
1174+lines t = let (l,t') = break ((==) '\n') t
1175 in l : if null t' then []
1175 in l : if null t' then []
1176 else lines (tail t')
1176 else lines (tail t')