on master help sign in
Rename find to findBy, and findAll to find.
0401b67Bryan O'Sullivan
Data/Text.hs+2−2
@@ -1066,10 +1066,10 @@ filter p t = unstream (S.filter p (stream t))
1066-- Laws:
1066-- Laws:
1067--
1067--
1068-- > concat (prefix : matches) == haystack
1068-- > concat (prefix : matches) == haystack
1069−-- > where (prefix, matches) = findAll needle haystack
1069+-- > where (prefix, matches) = find needle haystack
1070find :: Text -> Text -> (Text, [Text])
1070find :: Text -> Text -> (Text, [Text])
1071find pat@(Text _ _ plen) src@(Text sarr soff slen)
1071find pat@(Text _ _ plen) src@(Text sarr soff slen)
1072− | plen <= 0 = emptyError "findAll"
1072+ | plen <= 0 = emptyError "find"
1073 | otherwise = (h,t)
1073 | otherwise = (h,t)
1074 where
1074 where
1075 (h:t) = go 0 (search 0)
1075 (h:t) = go 0 (search 0)
Data/Text/Fusion/Common.hs+5−5
@@ -88,7 +88,7 @@ module Data.Text.Fusion.Common
88 , filter
88 , filter
89
89
90 -- * Indexing
90 -- * Indexing
91− , find
91+ , findBy
92 , indexI
92 , indexI
93 , findIndexI
93 , findIndexI
94 , findIndicesI
94 , findIndicesI
@@ -729,19 +729,19 @@ elem w (Stream next s0 _len) = loop_elem s0
729-------------------------------------------------------------------------------
729-------------------------------------------------------------------------------
730-- ** Searching with a predicate
730-- ** Searching with a predicate
731
731
732−-- | /O(n)/ The 'find' function takes a predicate and a stream,
732+-- | /O(n)/ The 'findBy' function takes a predicate and a stream,
733-- and returns the first element in matching the predicate, or 'Nothing'
733-- and returns the first element in matching the predicate, or 'Nothing'
734-- if there is no such element.
734-- if there is no such element.
735
735
736−find :: (Char -> Bool) -> Stream Char -> Maybe Char
736+findBy :: (Char -> Bool) -> Stream Char -> Maybe Char
737−find p (Stream next s0 _len) = loop_find s0
737+findBy p (Stream next s0 _len) = loop_find s0
738 where
738 where
739 loop_find !s = case next s of
739 loop_find !s = case next s of
740 Done -> Nothing
740 Done -> Nothing
741 Skip s' -> loop_find s'
741 Skip s' -> loop_find s'
742 Yield x s' | p x -> Just x
742 Yield x s' | p x -> Just x
743 | otherwise -> loop_find s'
743 | otherwise -> loop_find s'
744−{-# INLINE [0] find #-}
744+{-# INLINE [0] findBy #-}
745
745
746-- | /O(n)/ Stream index (subscript) operator, starting from 0.
746-- | /O(n)/ Stream index (subscript) operator, starting from 0.
747indexI :: Integral a => Stream Char -> a -> Char
747indexI :: Integral a => Stream Char -> a -> Char
Data/Text/Lazy.hs+6−6
@@ -148,7 +148,7 @@ module Data.Text.Lazy
148 -- * Searching
148 -- * Searching
149 , elem
149 , elem
150 , filter
150 , filter
151− , find
151+ , findBy
152 , partition
152 , partition
153
153
154 -- , findSubstring
154 -- , findSubstring
@@ -1064,12 +1064,12 @@ filter :: (Char -> Bool) -> Text -> Text
1064filter p t = unstream (S.filter p (stream t))
1064filter p t = unstream (S.filter p (stream t))
1065{-# INLINE filter #-}
1065{-# INLINE filter #-}
1066
1066
1067−-- | /O(n)/ The 'find' function takes a predicate and a 'Text',
1067+-- | /O(n)/ The 'findBy' function takes a predicate and a 'Text', and
1068−-- and returns the first element in matching the predicate, or 'Nothing'
1068+-- returns the first element in matching the predicate, or 'Nothing'
1069-- if there is no such element.
1069-- if there is no such element.
1070−find :: (Char -> Bool) -> Text -> Maybe Char
1070+findBy :: (Char -> Bool) -> Text -> Maybe Char
1071−find p t = S.find p (stream t)
1071+findBy p t = S.findBy p (stream t)
1072−{-# INLINE find #-}
1072+{-# INLINE findBy #-}
1073
1073
1074-- | /O(n)/ The 'partition' function takes a predicate and a 'Text',
1074-- | /O(n)/ The 'partition' function takes a predicate and a 'Text',
1075-- and returns the pair of 'Text's with elements which do and do not
1075-- and returns the pair of 'Text's with elements which do and do not
tests/Properties.hs+6−6
@@ -474,9 +474,9 @@ tl_elem c = L.elem c `eqP` TL.elem c
474sf_filter q p = (L.filter p . L.filter q) `eqP` (unpackS . S.filter p . S.filter q)
474sf_filter q p = (L.filter p . L.filter q) `eqP` (unpackS . S.filter p . S.filter q)
475t_filter p = L.filter p `eqP` (unpackS . T.filter p)
475t_filter p = L.filter p `eqP` (unpackS . T.filter p)
476tl_filter p = L.filter p `eqP` (unpackS . TL.filter p)
476tl_filter p = L.filter p `eqP` (unpackS . TL.filter p)
477−sf_find q p = (L.find p . L.filter q) `eqP` (S.find p . S.filter q)
477+sf_findBy q p = (L.find p . L.filter q) `eqP` (S.findBy p . S.filter q)
478−t_find p = L.find p `eqP` T.find p
478+t_findBy p = L.find p `eqP` T.findBy p
479−tl_find p = L.find p `eqP` TL.find p
479+tl_findBy p = L.find p `eqP` TL.findBy p
480t_partition p = L.partition p `eqP` (unpack2 . T.partition p)
480t_partition p = L.partition p `eqP` (unpack2 . T.partition p)
481tl_partition p = L.partition p `eqP` (unpack2 . TL.partition p)
481tl_partition p = L.partition p `eqP` (unpack2 . TL.partition p)
482
482
@@ -853,9 +853,9 @@ tests = [
853 testProperty "sf_filter" sf_filter,
853 testProperty "sf_filter" sf_filter,
854 testProperty "t_filter" t_filter,
854 testProperty "t_filter" t_filter,
855 testProperty "tl_filter" tl_filter,
855 testProperty "tl_filter" tl_filter,
856− testProperty "sf_find" sf_find,
856+ testProperty "sf_findBy" sf_findBy,
857− testProperty "t_find" t_find,
857+ testProperty "t_findBy" t_findBy,
858− testProperty "tl_find" tl_find,
858+ testProperty "tl_findBy" tl_findBy,
859 testProperty "t_partition" t_partition,
859 testProperty "t_partition" t_partition,
860 testProperty "tl_partition" tl_partition
860 testProperty "tl_partition" tl_partition
861 ],
861 ],