on master help sign in
Remove countChar from the public API.

--HG-- extra : convert_revision : 9137a772c2df2a816180e4d69c08a73ac2faa5dd

commit4c25b63aecf5a4254fe7f3d8f059d21cdb8aaa83 authorBryan O'Sullivan <bos@serpentine.com> dateSun 16 Aug 2009, 06:32 (17 years ago) parente2e3271
3 files changed+12−11
Data/Text.hs+5−1 Data/Text/Lazy.hs+5−2 tests/Properties.hs+2−8
Data/Text.hs+5−1
@@ -157,7 +157,6 @@ module Data.Text
157157 , elemIndex
158158 , elemIndices
159159 , count
160− , countChar
161160
162161 -- * Zipping and unzipping
163162 , zip
@@ -1123,6 +1122,11 @@ count pat src0
11231122 | otherwise = search (unsafeTail s)
11241123{-# INLINE [1] count #-}
11251124
1125+{-# RULES
1126+"TEXT count/singleton -> countChar" [~1] forall c t.
1127+ count (singleton c) t = countChar c t
1128+ #-}
1129+
11261130-- | /O(n)/ The 'countChar' function returns the number of times the
11271131-- query element appears in the given 'Text'. Subject to fusion.
11281132countChar :: Char -> Text -> Int
Data/Text/Lazy.hs+5−2
@@ -160,7 +160,6 @@ module Data.Text.Lazy
160160 , elemIndex
161161 , elemIndices
162162 , count
163− , countChar
164163
165164 -- * Zipping and unzipping
166165 , zip
@@ -1132,12 +1131,16 @@ count pat src0
11321131 | otherwise = search (tail s)
11331132{-# INLINE [1] count #-}
11341133
1134+{-# RULES
1135+"LAZY TEXT count/singleton -> countChar" [~1] forall c t.
1136+ count (singleton c) t = countChar c t
1137+ #-}
1138+
11351139-- | /O(n)/ The 'countChar' function returns the number of times the
11361140-- query element appears in the given 'Text'. This function is subject
11371141-- to fusion.
11381142countChar :: Char -> Text -> Int64
11391143countChar c t = S.countChar c (stream t)
1140−{-# INLINE countChar #-}
11411144
11421145-- | /O(n)/ 'zip' takes two 'Text's and returns a list of
11431146-- corresponding pairs of bytes. If one input 'Text' is short,
tests/Properties.hs+2−8
@@ -397,7 +397,7 @@ t_splitTimesEnd_split (NotEmpty t) = T.splitTimesEnd maxBound t `eq` T.split t
397397tl_splitTimesEnd_split (NotEmpty t) = TL.splitTimesEnd maxBound t `eq` TL.split t
398398
399399t_splitWith p = splitWith p `eqP` (map unpackS . T.splitWith p)
400−t_splitWith_count c = (L.length . T.splitWith (==c)) `eq` ((1+) . T.countChar c)
400+t_splitWith_count c = (L.length . T.splitWith (==c)) `eq` ((1+) . T.count (T.singleton c))
401401t_splitWith_split c = T.splitWith (==c) `eq` T.split (T.singleton c)
402402tl_splitWith p = splitWith p `eqP` (map unpackS . TL.splitWith p)
403403
@@ -480,9 +480,6 @@ t_elemIndices c = L.elemIndices c`eqP` T.elemIndices c
480480tl_elemIndices c = (fmap fromIntegral . L.elemIndices c) `eqP` TL.elemIndices c
481481t_count t = (subtract 1 . L.length . T.split t) `eq` T.count t
482482tl_count t = (subtract 1 . L.genericLength . TL.split t) `eq` TL.count t
483−sf_countChar p c = (L.length . L.elemIndices c . L.filter p) `eqP` (S.countChar c . S.filter p)
484−t_countChar c = (L.length . L.elemIndices c) `eqP` T.countChar c
485−tl_countChar c = (fromIntegral . L.length . L.elemIndices c) `eqP` TL.countChar c
486483t_zip s = L.zip s `eqP` T.zip (packS s)
487484tl_zip s = L.zip s `eqP` TL.zip (packS s)
488485sf_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)
@@ -839,10 +836,7 @@ tests = [
839836 testProperty "t_elemIndices" t_elemIndices,
840837 testProperty "tl_elemIndices" tl_elemIndices,
841838 testProperty "t_count" t_count,
842− testProperty "tl_count" tl_count,
843− testProperty "sf_countChar" sf_countChar,
844− testProperty "t_countChar" t_countChar,
845− testProperty "tl_countChar" tl_countChar
839+ testProperty "tl_count" tl_count
846840 ],
847841
848842 testGroup "zips" [