@@ -133,7 +133,7 @@ module Data.Text
133 , findIndices
133 , findIndices
134 , elemIndex
134 , elemIndex
135 , elemIndices
135 , elemIndices
136− -- , count
136+ , count
138 -- * Zipping and unzipping
138 -- * Zipping and unzipping
139 , zipWith
139 , zipWith
@@ -561,9 +561,9 @@ take n t@(Text arr off len)
561 | n >= len = t
561 | n >= len = t
562 | otherwise = Text arr off (loop 0 0)
562 | otherwise = Text arr off (loop 0 0)
564− loop !i !count
564+ loop !i !cnt
565− | i >= len || count >= n = i
565+ | i >= len || cnt >= n = i
566− | otherwise = loop (i+d) (count+1)
566+ | otherwise = loop (i+d) (cnt+1)
567 where d = iter_ t i
567 where d = iter_ t i
568{-# INLINE [1] take #-}
568{-# INLINE [1] take #-}
@@ -583,9 +583,9 @@ drop n t@(Text arr off len)
583 | n >= len = empty
583 | n >= len = empty
584 | otherwise = loop 0 0
584 | otherwise = loop 0 0
585 where end = off + len
585 where end = off + len
586− loop !i !count
586+ loop !i !cnt
587− | i >= end || count >= n = Text arr (off+i) (len-i)
587+ | i >= end || cnt >= n = Text arr (off+i) (len-i)
588− | otherwise = loop (i+d) (count+1)
588+ | otherwise = loop (i+d) (cnt+1)
589 where d = iter_ t i
589 where d = iter_ t i
590{-# INLINE [1] drop #-}
590{-# INLINE [1] drop #-}
@@ -640,10 +640,10 @@ splitAt n t@(Text arr off len)
640 | n >= len = (t, empty)
640 | n >= len = (t, empty)
641 | otherwise = (Text arr off k, Text arr (off+k) (len-k))
641 | otherwise = (Text arr off k, Text arr (off+k) (len-k))
642 where k = loop 0 0
642 where k = loop 0 0
643− loop !i !count
643+ loop !i !cnt
644− | i >= len || count >= n = i
644+ | i >= len || cnt >= n = i
645− | otherwise = loop (i+d) (count+1)
645+ | otherwise = loop (i+d) (cnt+1)
646− where d = iter_ t i
646+ where d = iter_ t i
647{-# INLINE splitAt #-}
647{-# INLINE splitAt #-}
649-- | /O(n)/ 'span', applied to a predicate @p@ and text @t@, returns a
649-- | /O(n)/ 'span', applied to a predicate @p@ and text @t@, returns a
@@ -852,6 +852,13 @@ elemIndices :: Char -> Text -> [Int]
852elemIndices c t = S.elemIndices c (stream t)
852elemIndices c t = S.elemIndices c (stream t)
853{-# INLINE elemIndices #-}
853{-# INLINE elemIndices #-}
855+-- | /O(n)/ The 'count' function returns the number of times the query
856+-- element appears in the given 'Text'. This function is subject to
858+count :: Char -> Text -> Int
859+count c t = S.count c (stream t)
855-------------------------------------------------------------------------------
862-------------------------------------------------------------------------------
856-- * Zipping
863-- * Zipping