on master help sign in
Rename count to countChar.

--HG-- extra : convert_revision : 1b55cae86640a82e8c8b446441297b1496c90f7c

commit42e260d954c054860957aab19a291f4738a9a98d authorBryan O'Sullivan <bos@serpentine.com> dateSun 16 Aug 2009, 05:41 (17 years ago) parentda51d3a
6 files changed+31−31
Data/Text.hs+6−6 Data/Text/Fusion.hs+4−4 Data/Text/Fusion/Common.hs+6−6 Data/Text/Lazy.hs+7−7 Data/Text/Lazy/Fusion.hs+4−4 tests/Properties.hs+4−4
Data/Text.hs+6−6
@@ -156,7 +156,7 @@ module Data.Text
156156 , findIndices
157157 , elemIndex
158158 , elemIndices
159− , count
159+ , countChar
160160
161161 -- * Zipping and unzipping
162162 , zip
@@ -1100,11 +1100,11 @@ elemIndices :: Char -> Text -> [Int]
11001100elemIndices c t = S.elemIndices c (stream t)
11011101{-# INLINE elemIndices #-}
11021102
1103−-- | /O(n)/ The 'count' function returns the number of times the query
1104−-- element appears in the given 'Text'. Subject to fusion.
1105−count :: Char -> Text -> Int
1106−count c t = S.count c (stream t)
1107−{-# INLINE count #-}
1103+-- | /O(n)/ The 'countChar' function returns the number of times the
1104+-- query element appears in the given 'Text'. Subject to fusion.
1105+countChar :: Char -> Text -> Int
1106+countChar c t = S.countChar c (stream t)
1107+{-# INLINE countChar #-}
11081108
11091109-------------------------------------------------------------------------------
11101110-- * Zipping
Data/Text/Fusion.hs+4−4
@@ -44,7 +44,7 @@ module Data.Text.Fusion
4444 , findIndexOrEnd
4545 , elemIndex
4646 , elemIndices
47− , count
47+ , countChar
4848 ) where
4949
5050import Prelude (Bool(..), Char, Eq(..), Maybe(..), Monad(..), Int,
@@ -229,6 +229,6 @@ elemIndices = S.elemIndicesI
229229
230230-- | /O(n)/ The 'count' function returns the number of times the query
231231-- element appears in the given stream.
232−count :: Char -> Stream Char -> Int
233−count = S.countI
234−{-# INLINE [0] count #-}
232+countChar :: Char -> Stream Char -> Int
233+countChar = S.countCharI
234+{-# INLINE [0] countChar #-}
Data/Text/Fusion/Common.hs+6−6
@@ -94,7 +94,7 @@ module Data.Text.Fusion.Common
9494 , findIndicesI
9595 , elemIndexI
9696 , elemIndicesI
97− , countI
97+ , countCharI
9898
9999 -- * Zipping and unzipping
100100 , zipWith
@@ -840,17 +840,17 @@ elemIndicesI a (Stream next s0 _len) = loop 0 s0
840840 | otherwise -> loop (i+1) s'
841841{-# INLINE [0] elemIndicesI #-}
842842
843−-- | /O(n)/ The 'count' function returns the number of times the query
844−-- element appears in the given stream.
845−countI :: Integral a => Char -> Stream Char -> a
846−countI a (Stream next s0 _len) = loop 0 s0
843+-- | /O(n)/ The 'countCharI' function returns the number of times the
844+-- query element appears in the given stream.
845+countCharI :: Integral a => Char -> Stream Char -> a
846+countCharI a (Stream next s0 _len) = loop 0 s0
847847 where
848848 loop !i !s = case next s of
849849 Done -> i
850850 Skip s' -> loop i s'
851851 Yield x s' | a == x -> loop (i+1) s'
852852 | otherwise -> loop i s'
853−{-# INLINE [0] countI #-}
853+{-# INLINE [0] countCharI #-}
854854
855855streamError :: String -> String -> a
856856streamError func msg = P.error $ "Data.Text.Fusion.Common." ++ func ++ ": " ++ msg
Data/Text/Lazy.hs+7−7
@@ -159,7 +159,7 @@ module Data.Text.Lazy
159159 , findIndices
160160 , elemIndex
161161 , elemIndices
162− , count
162+ , countChar
163163
164164 -- * Zipping and unzipping
165165 , zip
@@ -1109,12 +1109,12 @@ elemIndices :: Char -> Text -> [Int64]
11091109elemIndices c t = S.elemIndices c (stream t)
11101110{-# INLINE elemIndices #-}
11111111
1112−-- | /O(n)/ The 'count' function returns the number of times the query
1113−-- element appears in the given 'Text'. This function is subject to
1114−-- fusion.
1115−count :: Char -> Text -> Int64
1116−count c t = S.count c (stream t)
1117−{-# INLINE count #-}
1112+-- | /O(n)/ The 'countChar' function returns the number of times the
1113+-- query element appears in the given 'Text'. This function is subject
1114+-- to fusion.
1115+countChar :: Char -> Text -> Int64
1116+countChar c t = S.countChar c (stream t)
1117+{-# INLINE countChar #-}
11181118
11191119-- | /O(n)/ 'zip' takes two 'Text's and returns a list of
11201120-- corresponding pairs of bytes. If one input 'Text' is short,
Data/Text/Lazy/Fusion.hs+4−4
@@ -22,7 +22,7 @@ module Data.Text.Lazy.Fusion
2222 , findIndices
2323 , elemIndex
2424 , elemIndices
25− , count
25+ , countChar
2626 ) where
2727
2828import Prelude hiding (length)
@@ -134,6 +134,6 @@ elemIndices = S.elemIndicesI
134134
135135-- | /O(n)/ The 'count' function returns the number of times the query
136136-- element appears in the given stream.
137−count :: Char -> Stream Char -> Int64
138−count = S.countI
139−{-# INLINE [0] count #-}
137+countChar :: Char -> Stream Char -> Int64
138+countChar = S.countCharI
139+{-# INLINE [0] countChar #-}
tests/Properties.hs+4−4
@@ -395,7 +395,7 @@ tl_splitTimesEnd_split t = TL.splitTimesEnd maxBound t `eq` TL.split t
395395tl_split_i t = id `eq` (TL.intercalate t . TL.split t)
396396
397397t_splitWith p = splitWith p `eqP` (map unpackS . T.splitWith p)
398−t_splitWith_count c = (L.length . T.splitWith (==c)) `eq` ((1+) . T.count c)
398+t_splitWith_count c = (L.length . T.splitWith (==c)) `eq` ((1+) . T.countChar c)
399399t_splitWith_split c = T.splitWith (==c) `eq` T.split (T.singleton c)
400400tl_splitWith p = splitWith p `eqP` (map unpackS . TL.splitWith p)
401401
@@ -476,9 +476,9 @@ tl_elemIndex c = (fmap fromIntegral . L.elemIndex c) `eqP` TL.elemIndex c
476476sf_elemIndices p c= (L.elemIndices c . L.filter p) `eqP` (S.elemIndices c . S.filter p)
477477t_elemIndices c = L.elemIndices c`eqP` T.elemIndices c
478478tl_elemIndices c = (fmap fromIntegral . L.elemIndices c) `eqP` TL.elemIndices c
479−sf_count p c = (L.length . L.elemIndices c . L.filter p) `eqP` (S.count c . S.filter p)
480−t_count c = (L.length . L.elemIndices c) `eqP` T.count c
481−tl_count c = (fromIntegral . L.length . L.elemIndices c) `eqP` TL.count c
479+sf_count p c = (L.length . L.elemIndices c . L.filter p) `eqP` (S.countChar c . S.filter p)
480+t_count c = (L.length . L.elemIndices c) `eqP` T.countChar c
481+tl_count c = (fromIntegral . L.length . L.elemIndices c) `eqP` TL.countChar c
482482t_zip s = L.zip s `eqP` T.zip (packS s)
483483tl_zip s = L.zip s `eqP` TL.zip (packS s)
484484sf_zipWith p c s = (L.zipWith c (L.filter p s) . L.filter p) `eqP` (unpackS . S.zipWith c (S.filter p $ packS s) . S.filter p)