@@ -133,7 +133,7 @@ module Data.Text
133133 , findIndices
134134 , elemIndex
135135 , elemIndices
136− -- , count
136+ , count
137137
138138 -- * Zipping and unzipping
139139 , zipWith
@@ -561,9 +561,9 @@ take n t@(Text arr off len)
561561 | n >= len = t
562562 | otherwise = Text arr off (loop 0 0)
563563 where
564− loop !i !count
565− | i >= len || count >= n = i
566− | otherwise = loop (i+d) (count+1)
564+ loop !i !cnt
565+ | i >= len || cnt >= n = i
566+ | otherwise = loop (i+d) (cnt+1)
567567 where d = iter_ t i
568568{-# INLINE [1] take #-}
569569
@@ -583,9 +583,9 @@ drop n t@(Text arr off len)
583583 | n >= len = empty
584584 | otherwise = loop 0 0
585585 where end = off + len
586− loop !i !count
587− | i >= end || count >= n = Text arr (off+i) (len-i)
588− | otherwise = loop (i+d) (count+1)
586+ loop !i !cnt
587+ | i >= end || cnt >= n = Text arr (off+i) (len-i)
588+ | otherwise = loop (i+d) (cnt+1)
589589 where d = iter_ t i
590590{-# INLINE [1] drop #-}
591591
@@ -640,10 +640,10 @@ splitAt n t@(Text arr off len)
640640 | n >= len = (t, empty)
641641 | otherwise = (Text arr off k, Text arr (off+k) (len-k))
642642 where k = loop 0 0
643− loop !i !count
644− | i >= len || count >= n = i
645− | otherwise = loop (i+d) (count+1)
646− where d = iter_ t i
643+ loop !i !cnt
644+ | i >= len || cnt >= n = i
645+ | otherwise = loop (i+d) (cnt+1)
646+ where d = iter_ t i
647647{-# INLINE splitAt #-}
648648
649649-- | /O(n)/ 'span', applied to a predicate @p@ and text @t@, returns a
@@ -852,6 +852,13 @@ elemIndices :: Char -> Text -> [Int]
852852elemIndices c t = S.elemIndices c (stream t)
853853{-# INLINE elemIndices #-}
854854
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
857+-- fusion.
858+count :: Char -> Text -> Int
859+count c t = S.count c (stream t)
860+{-# INLINE count #-}
861+
855862-------------------------------------------------------------------------------
856863-- * Zipping
857864