on master help sign in
rename splitBySuffix to splitWithSuffix

"With" gives a better idea that we are keeping the suffix.

commitfc957922accb85d153373793997893d288a4ad37 authorHarendra Kumar <harendra.kumar@gmail.com> dateTue 13 Aug 2019, 15:47 (7 years ago) parentfab6734
5 files changed+25−25
README.md+2−2 examples/HandleIO.hs+2−2 src/Streamly/Internal.hs+1−1 src/Streamly/Prelude.hs+2−2 src/Streamly/Prelude/Internal.hs+18−18
README.md+2−2
@@ -454,7 +454,7 @@ main = withArg wcl >>= print
454454``` haskell
455455avgll =
456456 S.runFold avg
457− . S.splitBySuffix (== 10) FL.length
457+ . S.splitWithSuffix (== 10) FL.length
458458 . FH.read
459459
460460 where avg = (/) <$> toDouble FL.sum <*> toDouble FL.length
@@ -469,7 +469,7 @@ main = withArg avgll >>= print
469469llhisto =
470470 S.runFold (FL.classify FL.length)
471471 . S.map bucket
472− . S.splitBySuffix (== 10) FL.length
472+ . S.splitWithSuffix (== 10) FL.length
473473 . FH.read
474474
475475 where
examples/HandleIO.hs+2−2
@@ -45,7 +45,7 @@ grepc pat src = print . (subtract 1) =<< (S.length
4545
4646avgll :: FH.Handle -> IO ()
4747avgll src = print =<< (S.runFold avg
48− $ S.splitBySuffix (== ord' '\n') FL.length
48+ $ S.splitWithSuffix (== ord' '\n') FL.length
4949 $ FH.read src)
5050 where avg = (/) <$> toDouble FL.sum <*> toDouble FL.length
5151 toDouble = fmap (fromIntegral :: Int -> Double)
@@ -53,7 +53,7 @@ avgll src = print =<< (S.runFold avg
5353llhisto :: FH.Handle -> IO ()
5454llhisto src = print =<< (S.runFold (FL.classify FL.length)
5555 $ S.map bucket
56− $ S.splitBySuffix (== ord' '\n') FL.length
56+ $ S.splitWithSuffix (== ord' '\n') FL.length
5757 $ FH.read src)
5858 where
5959 bucket n = let i = n `div` 10 in if i > 9 then (9,n) else (i,n)
src/Streamly/Internal.hs+1−1
@@ -44,7 +44,7 @@ module Streamly.Internal
4444 , splitOnSeq
4545 , splitOnSuffixSeq
4646 , splitBySeq
47− , splitBySuffixSeq
47+ , splitWithSuffixSeq
4848
4949 , tapAsync
5050
src/Streamly/Prelude.hs+2−2
@@ -494,7 +494,7 @@ module Streamly.Prelude
494494 -- the separator may be kept attached to the stream segments in prefix or
495495 -- suffix position or as a separate element in infix position. Combinators
496496 -- like 'splitOn' that use @On@ in their names drop the separator and
497− -- combinators that use 'By' in their names keep the separator. When a
497+ -- combinators that use 'With' in their names keep the separator. When a
498498 -- segment is missing it is considered as empty, therefore, we never
499499 -- encounter an error in parsing.
500500
@@ -504,7 +504,7 @@ module Streamly.Prelude
504504 -- , splitOnPrefix
505505
506506 -- , splitBy
507− , splitBySuffix
507+ , splitWithSuffix
508508 -- , splitByPrefix
509509 , wordsBy -- strip, compact and split
510510
src/Streamly/Prelude/Internal.hs+18−18
@@ -267,7 +267,7 @@ module Streamly.Prelude.Internal
267267 -- , splitOnPrefix
268268
269269 -- , splitBy
270− , splitBySuffix
270+ , splitWithSuffix
271271 -- , splitByPrefix
272272 , wordsBy -- stripAndCompactBy
273273
@@ -278,7 +278,7 @@ module Streamly.Prelude.Internal
278278
279279 -- Keeping the delimiters
280280 , splitBySeq
281− , splitBySuffixSeq
281+ , splitWithSuffixSeq
282282 -- , splitByPrefixSeq
283283 -- , wordsBySeq
284284
@@ -2249,7 +2249,7 @@ intervalsOf
22492249 :: (IsStream t, MonadAsync m)
22502250 => Double -> Fold m a b -> t m a -> t m b
22512251intervalsOf n f xs =
2252− splitBySuffix isNothing (FL.lcatMaybes f)
2252+ splitWithSuffix isNothing (FL.lcatMaybes f)
22532253 (intersperseByTime n (return Nothing) (Serial.map Just xs))
22542254
22552255------------------------------------------------------------------------------
@@ -2609,30 +2609,30 @@ wordsBy predicate f m =
26092609-- | Like 'splitOnSuffix' but keeps the suffix attached to the resulting
26102610-- splits.
26112611--
2612−-- > splitBySuffix' p xs = S.toList $ S.splitBySuffix p (FL.toList) (S.fromList xs)
2612+-- > splitWithSuffix' p xs = S.toList $ S.splitWithSuffix p (FL.toList) (S.fromList xs)
26132613--
2614−-- >>> splitBySuffix' (== '.') ""
2614+-- >>> splitWithSuffix' (== '.') ""
26152615-- []
26162616--
2617−-- >>> splitBySuffix' (== '.') "."
2617+-- >>> splitWithSuffix' (== '.') "."
26182618-- ["."]
26192619--
2620−-- >>> splitBySuffix' (== '.') "a"
2620+-- >>> splitWithSuffix' (== '.') "a"
26212621-- ["a"]
26222622--
2623−-- >>> splitBySuffix' (== '.') ".a"
2623+-- >>> splitWithSuffix' (== '.') ".a"
26242624-- > [".","a"]
26252625--
2626−-- >>> splitBySuffix' (== '.') "a."
2626+-- >>> splitWithSuffix' (== '.') "a."
26272627-- > ["a."]
26282628--
2629−-- >>> splitBySuffix' (== '.') "a.b"
2629+-- >>> splitWithSuffix' (== '.') "a.b"
26302630-- > ["a.","b"]
26312631--
2632−-- >>> splitBySuffix' (== '.') "a.b."
2632+-- >>> splitWithSuffix' (== '.') "a.b."
26332633-- > ["a.","b."]
26342634--
2635−-- >>> splitBySuffix' (== '.') "a..b.."
2635+-- >>> splitWithSuffix' (== '.') "a..b.."
26362636-- > ["a.",".","b.","."]
26372637--
26382638-- @since 0.7.0
@@ -2640,11 +2640,11 @@ wordsBy predicate f m =
26402640-- This can be considered as an n-fold version of 'breakPost' where we apply
26412641-- 'breakPost' successively on the input stream.
26422642--
2643−{-# INLINE splitBySuffix #-}
2644−splitBySuffix
2643+{-# INLINE splitWithSuffix #-}
2644+splitWithSuffix
26452645 :: (IsStream t, Monad m)
26462646 => (a -> Bool) -> Fold m a b -> t m a -> t m b
2647−splitBySuffix predicate f m =
2647+splitWithSuffix predicate f m =
26482648 D.fromStreamD $ D.splitSuffixBy' predicate f (D.toStreamD m)
26492649
26502650------------------------------------------------------------------------------
@@ -2863,11 +2863,11 @@ splitBySeq patt f m = intersperseM (runFold f (A.read patt)) $ splitOnSeq patt f
28632863-- > ["a.",".","b.","."]
28642864--
28652865-- @since 0.7.0
2866−{-# INLINE splitBySuffixSeq #-}
2867−splitBySuffixSeq
2866+{-# INLINE splitWithSuffixSeq #-}
2867+splitWithSuffixSeq
28682868 :: (IsStream t, MonadIO m, Storable a, Enum a, Eq a)
28692869 => Array a -> Fold m a b -> t m a -> t m b
2870−splitBySuffixSeq patt f m =
2870+splitWithSuffixSeq patt f m =
28712871 D.fromStreamD $ D.splitSuffixOn True patt f (D.toStreamD m)
28722872
28732873{-