on master help sign in
Rename count to countChar.
42e260dBryan O'Sullivan
Data/Text.hs+6−6
@@ -156,7 +156,7 @@ module Data.Text
156 , findIndices
156 , findIndices
157 , elemIndex
157 , elemIndex
158 , elemIndices
158 , elemIndices
159− , count
159+ , countChar
160
160
161 -- * Zipping and unzipping
161 -- * Zipping and unzipping
162 , zip
162 , zip
@@ -1100,11 +1100,11 @@ elemIndices :: Char -> Text -> [Int]
1100elemIndices c t = S.elemIndices c (stream t)
1100elemIndices c t = S.elemIndices c (stream t)
1101{-# INLINE elemIndices #-}
1101{-# INLINE elemIndices #-}
1102
1102
1103−-- | /O(n)/ The 'count' function returns the number of times the query
1103+-- | /O(n)/ The 'countChar' function returns the number of times the
1104−-- element appears in the given 'Text'. Subject to fusion.
1104+-- query element appears in the given 'Text'. Subject to fusion.
1105−count :: Char -> Text -> Int
1105+countChar :: Char -> Text -> Int
1106−count c t = S.count c (stream t)
1106+countChar c t = S.countChar c (stream t)
1107−{-# INLINE count #-}
1107+{-# INLINE countChar #-}
1108
1108
1109-------------------------------------------------------------------------------
1109-------------------------------------------------------------------------------
1110-- * Zipping
1110-- * Zipping
Data/Text/Fusion.hs+4−4
@@ -44,7 +44,7 @@ module Data.Text.Fusion
44 , findIndexOrEnd
44 , findIndexOrEnd
45 , elemIndex
45 , elemIndex
46 , elemIndices
46 , elemIndices
47− , count
47+ , countChar
48 ) where
48 ) where
49
49
50import Prelude (Bool(..), Char, Eq(..), Maybe(..), Monad(..), Int,
50import Prelude (Bool(..), Char, Eq(..), Maybe(..), Monad(..), Int,
@@ -229,6 +229,6 @@ elemIndices = S.elemIndicesI
229
229
230-- | /O(n)/ The 'count' function returns the number of times the query
230-- | /O(n)/ The 'count' function returns the number of times the query
231-- element appears in the given stream.
231-- element appears in the given stream.
232−count :: Char -> Stream Char -> Int
232+countChar :: Char -> Stream Char -> Int
233−count = S.countI
233+countChar = S.countCharI
234−{-# INLINE [0] count #-}
234+{-# INLINE [0] countChar #-}
Data/Text/Fusion/Common.hs+6−6
@@ -94,7 +94,7 @@ module Data.Text.Fusion.Common
94 , findIndicesI
94 , findIndicesI
95 , elemIndexI
95 , elemIndexI
96 , elemIndicesI
96 , elemIndicesI
97− , countI
97+ , countCharI
98
98
99 -- * Zipping and unzipping
99 -- * Zipping and unzipping
100 , zipWith
100 , zipWith
@@ -840,17 +840,17 @@ elemIndicesI a (Stream next s0 _len) = loop 0 s0
840 | otherwise -> loop (i+1) s'
840 | otherwise -> loop (i+1) s'
841{-# INLINE [0] elemIndicesI #-}
841{-# INLINE [0] elemIndicesI #-}
842
842
843−-- | /O(n)/ The 'count' function returns the number of times the query
843+-- | /O(n)/ The 'countCharI' function returns the number of times the
844−-- element appears in the given stream.
844+-- query element appears in the given stream.
845−countI :: Integral a => Char -> Stream Char -> a
845+countCharI :: Integral a => Char -> Stream Char -> a
846−countI a (Stream next s0 _len) = loop 0 s0
846+countCharI a (Stream next s0 _len) = loop 0 s0
847 where
847 where
848 loop !i !s = case next s of
848 loop !i !s = case next s of
849 Done -> i
849 Done -> i
850 Skip s' -> loop i s'
850 Skip s' -> loop i s'
851 Yield x s' | a == x -> loop (i+1) s'
851 Yield x s' | a == x -> loop (i+1) s'
852 | otherwise -> loop i s'
852 | otherwise -> loop i s'
853−{-# INLINE [0] countI #-}
853+{-# INLINE [0] countCharI #-}
854
854
855streamError :: String -> String -> a
855streamError :: String -> String -> a
856streamError func msg = P.error $ "Data.Text.Fusion.Common." ++ func ++ ": " ++ msg
856streamError func msg = P.error $ "Data.Text.Fusion.Common." ++ func ++ ": " ++ msg
Data/Text/Lazy.hs+7−7
@@ -159,7 +159,7 @@ module Data.Text.Lazy
159 , findIndices
159 , findIndices
160 , elemIndex
160 , elemIndex
161 , elemIndices
161 , elemIndices
162− , count
162+ , countChar
163
163
164 -- * Zipping and unzipping
164 -- * Zipping and unzipping
165 , zip
165 , zip
@@ -1109,12 +1109,12 @@ elemIndices :: Char -> Text -> [Int64]
1109elemIndices c t = S.elemIndices c (stream t)
1109elemIndices c t = S.elemIndices c (stream t)
1110{-# INLINE elemIndices #-}
1110{-# INLINE elemIndices #-}
1111
1111
1112−-- | /O(n)/ The 'count' function returns the number of times the query
1112+-- | /O(n)/ The 'countChar' function returns the number of times the
1113−-- element appears in the given 'Text'. This function is subject to
1113+-- query element appears in the given 'Text'. This function is subject
1114−-- fusion.
1114+-- to fusion.
1115−count :: Char -> Text -> Int64
1115+countChar :: Char -> Text -> Int64
1116−count c t = S.count c (stream t)
1116+countChar c t = S.countChar c (stream t)
1117−{-# INLINE count #-}
1117+{-# INLINE countChar #-}
1118
1118
1119-- | /O(n)/ 'zip' takes two 'Text's and returns a list of
1119-- | /O(n)/ 'zip' takes two 'Text's and returns a list of
1120-- corresponding pairs of bytes. If one input 'Text' is short,
1120-- 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
22 , findIndices
22 , findIndices
23 , elemIndex
23 , elemIndex
24 , elemIndices
24 , elemIndices
25− , count
25+ , countChar
26 ) where
26 ) where
27
27
28import Prelude hiding (length)
28import Prelude hiding (length)
@@ -134,6 +134,6 @@ elemIndices = S.elemIndicesI
134
134
135-- | /O(n)/ The 'count' function returns the number of times the query
135-- | /O(n)/ The 'count' function returns the number of times the query
136-- element appears in the given stream.
136-- element appears in the given stream.
137−count :: Char -> Stream Char -> Int64
137+countChar :: Char -> Stream Char -> Int64
138−count = S.countI
138+countChar = S.countCharI
139−{-# INLINE [0] count #-}
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
395tl_split_i t = id `eq` (TL.intercalate t . TL.split t)
395tl_split_i t = id `eq` (TL.intercalate t . TL.split t)
396
396
397t_splitWith p = splitWith p `eqP` (map unpackS . T.splitWith p)
397t_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)
399t_splitWith_split c = T.splitWith (==c) `eq` T.split (T.singleton c)
399t_splitWith_split c = T.splitWith (==c) `eq` T.split (T.singleton c)
400tl_splitWith p = splitWith p `eqP` (map unpackS . TL.splitWith p)
400tl_splitWith p = splitWith p `eqP` (map unpackS . TL.splitWith p)
401
401
@@ -476,9 +476,9 @@ tl_elemIndex c = (fmap fromIntegral . L.elemIndex c) `eqP` TL.elemIndex c
476sf_elemIndices p c= (L.elemIndices c . L.filter p) `eqP` (S.elemIndices c . S.filter p)
476sf_elemIndices p c= (L.elemIndices c . L.filter p) `eqP` (S.elemIndices c . S.filter p)
477t_elemIndices c = L.elemIndices c`eqP` T.elemIndices c
477t_elemIndices c = L.elemIndices c`eqP` T.elemIndices c
478tl_elemIndices c = (fmap fromIntegral . L.elemIndices c) `eqP` TL.elemIndices c
478tl_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)
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.count c
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.count c
481+tl_count c = (fromIntegral . L.length . L.elemIndices c) `eqP` TL.countChar c
482t_zip s = L.zip s `eqP` T.zip (packS s)
482t_zip s = L.zip s `eqP` T.zip (packS s)
483tl_zip s = L.zip s `eqP` TL.zip (packS s)
483tl_zip s = L.zip s `eqP` TL.zip (packS s)
484sf_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)
484sf_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)