@@ -213,7 +213,7 @@ import qualified Data.Text.Internal.Fusion as S
213import qualified Data.Text.Internal.Fusion.Common as S
213import qualified Data.Text.Internal.Fusion.Common as S
214import Data.Text.Internal.Fusion (stream, reverseStream, unstream)
214import Data.Text.Internal.Fusion (stream, reverseStream, unstream)
215import Data.Text.Internal.Private (span_)
215import Data.Text.Internal.Private (span_)
216−import Data.Text.Internal (Text(..), empty, firstf, safe, textP)
216+import Data.Text.Internal (Text(..), empty, firstf, safe, text)
217import qualified Prelude as P
217import qualified Prelude as P
218import Data.Text.Unsafe (Iter(..), iter, iter_, lengthWord16, reverseIter,
218import Data.Text.Unsafe (Iter(..), iter, iter_, lengthWord16, reverseIter,
219 reverseIter_, unsafeHead, unsafeTail)
219 reverseIter_, unsafeHead, unsafeTail)
@@ -452,7 +452,7 @@ head t = S.head (stream t)
452uncons :: Text -> Maybe (Char, Text)
452uncons :: Text -> Maybe (Char, Text)
453uncons t@(Text arr off len)
453uncons t@(Text arr off len)
454 | len <= 0 = Nothing
454 | len <= 0 = Nothing
455− | otherwise = Just (c, textP arr (off+d) (len-d))
455+ | otherwise = Just (c, text arr (off+d) (len-d))
456 where Iter c d = iter t 0
456 where Iter c d = iter t 0
457{-# INLINE [1] uncons #-}
457{-# INLINE [1] uncons #-}
@@ -483,7 +483,7 @@ last (Text arr off len)
483tail :: Text -> Text
483tail :: Text -> Text
484tail t@(Text arr off len)
484tail t@(Text arr off len)
485 | len <= 0 = emptyError "tail"
485 | len <= 0 = emptyError "tail"
486− | otherwise = textP arr (off+d) (len-d)
486+ | otherwise = text arr (off+d) (len-d)
487 where d = iter_ t 0
487 where d = iter_ t 0
488{-# INLINE [1] tail #-}
488{-# INLINE [1] tail #-}
@@ -498,8 +498,8 @@ tail t@(Text arr off len)
498-- be non-empty. Subject to fusion.
498-- be non-empty. Subject to fusion.
499init :: Text -> Text
499init :: Text -> Text
500init (Text arr off len) | len <= 0 = emptyError "init"
500init (Text arr off len) | len <= 0 = emptyError "init"
501− | n >= 0xDC00 && n <= 0xDFFF = textP arr off (len-2)
501+ | n >= 0xDC00 && n <= 0xDFFF = text arr off (len-2)
502− | otherwise = textP arr off (len-1)
502+ | otherwise = text arr off (len-1)
504 n = A.unsafeIndex arr (off+len-1)
504 n = A.unsafeIndex arr (off+len-1)
505{-# INLINE [1] init #-}
505{-# INLINE [1] init #-}
@@ -1004,7 +1004,7 @@ take :: Int -> Text -> Text
1004take n t@(Text arr off len)
1004take n t@(Text arr off len)
1005 | n <= 0 = empty
1005 | n <= 0 = empty
1006 | n >= len = t
1006 | n >= len = t
1007− | otherwise = textP arr off (iterN n t)
1007+ | otherwise = text arr off (iterN n t)
1008{-# INLINE [1] take #-}
1008{-# INLINE [1] take #-}
1010iterN :: Int -> Text -> Int
1010iterN :: Int -> Text -> Int
@@ -1031,7 +1031,7 @@ takeEnd :: Int -> Text -> Text
1031takeEnd n t@(Text arr off len)
1031takeEnd n t@(Text arr off len)
1032 | n <= 0 = empty
1032 | n <= 0 = empty
1033 | n >= len = t
1033 | n >= len = t
1034− | otherwise = textP arr (off+i) (len-i)
1034+ | otherwise = text arr (off+i) (len-i)
1035 where i = iterNEnd n t
1035 where i = iterNEnd n t
1037iterNEnd :: Int -> Text -> Int
1037iterNEnd :: Int -> Text -> Int
@@ -1049,7 +1049,7 @@ drop :: Int -> Text -> Text
1049drop n t@(Text arr off len)
1049drop n t@(Text arr off len)
1050 | n <= 0 = t
1050 | n <= 0 = t
1051 | n >= len = empty
1051 | n >= len = empty
1052− | otherwise = textP arr (off+i) (len-i)
1052+ | otherwise = text arr (off+i) (len-i)
1053 where i = iterN n t
1053 where i = iterN n t
1054{-# INLINE [1] drop #-}
1054{-# INLINE [1] drop #-}
@@ -1070,7 +1070,7 @@ dropEnd :: Int -> Text -> Text
1070dropEnd n t@(Text arr off len)
1070dropEnd n t@(Text arr off len)
1071 | n <= 0 = t
1071 | n <= 0 = t
1072 | n >= len = empty
1072 | n >= len = empty
1073− | otherwise = textP arr off (iterNEnd n t)
1073+ | otherwise = text arr off (iterNEnd n t)
1075-- | /O(n)/ 'takeWhile', applied to a predicate @p@ and a 'Text',
1075-- | /O(n)/ 'takeWhile', applied to a predicate @p@ and a 'Text',
1076-- returns the longest prefix (possibly empty) of elements that
1076-- returns the longest prefix (possibly empty) of elements that
@@ -1079,7 +1079,7 @@ takeWhile :: (Char -> Bool) -> Text -> Text
1079takeWhile p t@(Text arr off len) = loop 0
1079takeWhile p t@(Text arr off len) = loop 0
1080 where loop !i | i >= len = t
1080 where loop !i | i >= len = t
1081 | p c = loop (i+d)
1081 | p c = loop (i+d)
1082− | otherwise = textP arr off i
1082+ | otherwise = text arr off i
1083 where Iter c d = iter t i
1083 where Iter c d = iter t i
1084{-# INLINE [1] takeWhile #-}
1084{-# INLINE [1] takeWhile #-}
@@ -1165,7 +1165,7 @@ splitAt n t@(Text arr off len)
1165 | n <= 0 = (empty, t)
1165 | n <= 0 = (empty, t)
1166 | n >= len = (t, empty)
1166 | n >= len = (t, empty)
1167 | otherwise = let k = iterN n t
1167 | otherwise = let k = iterN n t
1168− in (textP arr off k, textP arr (off+k) (len-k))
1168+ in (text arr off k, text arr (off+k) (len-k))
1170-- | /O(n)/ 'span', applied to a predicate @p@ and text @t@, returns
1170-- | /O(n)/ 'span', applied to a predicate @p@ and text @t@, returns
1171-- a pair whose first element is the longest prefix (possibly empty)
1171-- a pair whose first element is the longest prefix (possibly empty)
@@ -1188,7 +1188,7 @@ groupBy p = loop
1189 loop t@(Text arr off len)
1189 loop t@(Text arr off len)
1190 | null t = []
1190 | null t = []
1191− | otherwise = textP arr off n : loop (textP arr (off+n) (len-n))
1191+ | otherwise = text arr off n : loop (text arr (off+n) (len-n))
1192 where Iter c d = iter t 0
1192 where Iter c d = iter t 0
1193 n = d + findAIndexOrEnd (not . p c) (Text arr (off+d) (len-d))
1193 n = d + findAIndexOrEnd (not . p c) (Text arr (off+d) (len-d))
@@ -1247,8 +1247,8 @@ splitOn pat@(Text _ _ l) src@(Text arr off len)
1247 | isSingleton pat = split (== unsafeHead pat) src
1247 | isSingleton pat = split (== unsafeHead pat) src
1248 | otherwise = go 0 (indices pat src)
1248 | otherwise = go 0 (indices pat src)
1250− go !s (x:xs) = textP arr (s+off) (x-s) : go (x+l) xs
1250+ go !s (x:xs) = text arr (s+off) (x-s) : go (x+l) xs
1251− go s _ = [textP arr (s+off) (len-s)]
1251+ go s _ = [text arr (s+off) (len-s)]
1252{-# INLINE [1] splitOn #-}
1252{-# INLINE [1] splitOn #-}
1254{-# RULES
1254{-# RULES
@@ -1340,7 +1340,7 @@ breakOn pat src@(Text arr off len)
1340 | null pat = emptyError "breakOn"
1340 | null pat = emptyError "breakOn"
1341 | otherwise = case indices pat src of
1341 | otherwise = case indices pat src of
1342 [] -> (src, empty)
1342 [] -> (src, empty)
1343− (x:_) -> (textP arr off x, textP arr (off+x) (len-x))
1343+ (x:_) -> (text arr off x, text arr (off+x) (len-x))
1344{-# INLINE breakOn #-}
1344{-# INLINE breakOn #-}
1346-- | /O(n+m)/ Similar to 'breakOn', but searches from the end of the
1346-- | /O(n+m)/ Similar to 'breakOn', but searches from the end of the
@@ -1382,7 +1382,7 @@ breakOnAll pat src@(Text arr off slen)
1382 | otherwise = L.map step (indices pat src)
1382 | otherwise = L.map step (indices pat src)
1384 step x = (chunk 0 x, chunk x (slen-x))
1384 step x = (chunk 0 x, chunk x (slen-x))
1385− chunk !n !l = textP arr (n+off) l
1385+ chunk !n !l = text arr (n+off) l
1386{-# INLINE breakOnAll #-}
1386{-# INLINE breakOnAll #-}
1388-------------------------------------------------------------------------------
1388-------------------------------------------------------------------------------
@@ -1582,7 +1582,7 @@ isInfixOf needle haystack
1582-- > fnordLength _ = -1
1582-- > fnordLength _ = -1
1583stripPrefix :: Text -> Text -> Maybe Text
1583stripPrefix :: Text -> Text -> Maybe Text
1584stripPrefix p@(Text _arr _off plen) t@(Text arr off len)
1584stripPrefix p@(Text _arr _off plen) t@(Text arr off len)
1585− | p `isPrefixOf` t = Just $! textP arr (off+plen) (len-plen)
1585+ | p `isPrefixOf` t = Just $! text arr (off+plen) (len-plen)
1586 | otherwise = Nothing
1586 | otherwise = Nothing
1588-- | /O(n)/ Find the longest non-empty common prefix of two strings
1588-- | /O(n)/ Find the longest non-empty common prefix of two strings
@@ -1602,8 +1602,8 @@ commonPrefixes t0@(Text arr0 off0 len0) t1@(Text arr1 off1 len1) = go 0 0
1603 go !i !j | i < len0 && j < len1 && a == b = go (i+d0) (j+d1)
1603 go !i !j | i < len0 && j < len1 && a == b = go (i+d0) (j+d1)
1604 | i > 0 = Just (Text arr0 off0 i,
1604 | i > 0 = Just (Text arr0 off0 i,
1605− textP arr0 (off0+i) (len0-i),
1605+ text arr0 (off0+i) (len0-i),
1606− textP arr1 (off1+j) (len1-j))
1606+ text arr1 (off1+j) (len1-j))
1607 | otherwise = Nothing
1607 | otherwise = Nothing
1608 where Iter a d0 = iter t0 i
1608 where Iter a d0 = iter t0 i
1609 Iter b d1 = iter t1 j
1609 Iter b d1 = iter t1 j
@@ -1628,7 +1628,7 @@ commonPrefixes t0@(Text arr0 off0 len0) t1@(Text arr1 off1 len1) = go 0 0
1628-- > quuxLength _ = -1
1628-- > quuxLength _ = -1
1629stripSuffix :: Text -> Text -> Maybe Text
1629stripSuffix :: Text -> Text -> Maybe Text
1630stripSuffix p@(Text _arr _off plen) t@(Text arr off len)
1630stripSuffix p@(Text _arr _off plen) t@(Text arr off len)
1631− | p `isSuffixOf` t = Just $! textP arr off (len-plen)
1631+ | p `isSuffixOf` t = Just $! text arr off (len-plen)
1632 | otherwise = Nothing
1632 | otherwise = Nothing
1634-- | Add a list of non-negative numbers. Errors out on overflow.
1634-- | Add a list of non-negative numbers. Errors out on overflow.