on master help sign in
rename splitBySuffix to splitWithSuffix
fc95792Harendra Kumar
README.md+2−2
@@ -454,7 +454,7 @@ main = withArg wcl >>= print
454``` haskell
454``` haskell
455avgll =
455avgll =
456 S.runFold avg
456 S.runFold avg
457− . S.splitBySuffix (== 10) FL.length
457+ . S.splitWithSuffix (== 10) FL.length
458 . FH.read
458 . FH.read
459
459
460 where avg = (/) <$> toDouble FL.sum <*> toDouble FL.length
460 where avg = (/) <$> toDouble FL.sum <*> toDouble FL.length
@@ -469,7 +469,7 @@ main = withArg avgll >>= print
469llhisto =
469llhisto =
470 S.runFold (FL.classify FL.length)
470 S.runFold (FL.classify FL.length)
471 . S.map bucket
471 . S.map bucket
472− . S.splitBySuffix (== 10) FL.length
472+ . S.splitWithSuffix (== 10) FL.length
473 . FH.read
473 . FH.read
474
474
475 where
475 where
examples/HandleIO.hs+2−2
@@ -45,7 +45,7 @@ grepc pat src = print . (subtract 1) =<< (S.length
45
45
46avgll :: FH.Handle -> IO ()
46avgll :: FH.Handle -> IO ()
47avgll src = print =<< (S.runFold avg
47avgll src = print =<< (S.runFold avg
48− $ S.splitBySuffix (== ord' '\n') FL.length
48+ $ S.splitWithSuffix (== ord' '\n') FL.length
49 $ FH.read src)
49 $ FH.read src)
50 where avg = (/) <$> toDouble FL.sum <*> toDouble FL.length
50 where avg = (/) <$> toDouble FL.sum <*> toDouble FL.length
51 toDouble = fmap (fromIntegral :: Int -> Double)
51 toDouble = fmap (fromIntegral :: Int -> Double)
@@ -53,7 +53,7 @@ avgll src = print =<< (S.runFold avg
53llhisto :: FH.Handle -> IO ()
53llhisto :: FH.Handle -> IO ()
54llhisto src = print =<< (S.runFold (FL.classify FL.length)
54llhisto src = print =<< (S.runFold (FL.classify FL.length)
55 $ S.map bucket
55 $ S.map bucket
56− $ S.splitBySuffix (== ord' '\n') FL.length
56+ $ S.splitWithSuffix (== ord' '\n') FL.length
57 $ FH.read src)
57 $ FH.read src)
58 where
58 where
59 bucket n = let i = n `div` 10 in if i > 9 then (9,n) else (i,n)
59 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
44 , splitOnSeq
44 , splitOnSeq
45 , splitOnSuffixSeq
45 , splitOnSuffixSeq
46 , splitBySeq
46 , splitBySeq
47− , splitBySuffixSeq
47+ , splitWithSuffixSeq
48
48
49 , tapAsync
49 , tapAsync
50
50
src/Streamly/Prelude.hs+2−2
@@ -494,7 +494,7 @@ module Streamly.Prelude
494 -- the separator may be kept attached to the stream segments in prefix or
494 -- the separator may be kept attached to the stream segments in prefix or
495 -- suffix position or as a separate element in infix position. Combinators
495 -- suffix position or as a separate element in infix position. Combinators
496 -- like 'splitOn' that use @On@ in their names drop the separator and
496 -- 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
498 -- segment is missing it is considered as empty, therefore, we never
498 -- segment is missing it is considered as empty, therefore, we never
499 -- encounter an error in parsing.
499 -- encounter an error in parsing.
500
500
@@ -504,7 +504,7 @@ module Streamly.Prelude
504 -- , splitOnPrefix
504 -- , splitOnPrefix
505
505
506 -- , splitBy
506 -- , splitBy
507− , splitBySuffix
507+ , splitWithSuffix
508 -- , splitByPrefix
508 -- , splitByPrefix
509 , wordsBy -- strip, compact and split
509 , wordsBy -- strip, compact and split
510
510
src/Streamly/Prelude/Internal.hs+18−18
@@ -267,7 +267,7 @@ module Streamly.Prelude.Internal
267 -- , splitOnPrefix
267 -- , splitOnPrefix
268
268
269 -- , splitBy
269 -- , splitBy
270− , splitBySuffix
270+ , splitWithSuffix
271 -- , splitByPrefix
271 -- , splitByPrefix
272 , wordsBy -- stripAndCompactBy
272 , wordsBy -- stripAndCompactBy
273
273
@@ -278,7 +278,7 @@ module Streamly.Prelude.Internal
278
278
279 -- Keeping the delimiters
279 -- Keeping the delimiters
280 , splitBySeq
280 , splitBySeq
281− , splitBySuffixSeq
281+ , splitWithSuffixSeq
282 -- , splitByPrefixSeq
282 -- , splitByPrefixSeq
283 -- , wordsBySeq
283 -- , wordsBySeq
284
284
@@ -2249,7 +2249,7 @@ intervalsOf
2249 :: (IsStream t, MonadAsync m)
2249 :: (IsStream t, MonadAsync m)
2250 => Double -> Fold m a b -> t m a -> t m b
2250 => Double -> Fold m a b -> t m a -> t m b
2251intervalsOf n f xs =
2251intervalsOf n f xs =
2252− splitBySuffix isNothing (FL.lcatMaybes f)
2252+ splitWithSuffix isNothing (FL.lcatMaybes f)
2253 (intersperseByTime n (return Nothing) (Serial.map Just xs))
2253 (intersperseByTime n (return Nothing) (Serial.map Just xs))
2254
2254
2255------------------------------------------------------------------------------
2255------------------------------------------------------------------------------
@@ -2609,30 +2609,30 @@ wordsBy predicate f m =
2609-- | Like 'splitOnSuffix' but keeps the suffix attached to the resulting
2609-- | Like 'splitOnSuffix' but keeps the suffix attached to the resulting
2610-- splits.
2610-- splits.
2611--
2611--
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)
2613--
2613--
2614−-- >>> splitBySuffix' (== '.') ""
2614+-- >>> splitWithSuffix' (== '.') ""
2615-- []
2615-- []
2616--
2616--
2617−-- >>> splitBySuffix' (== '.') "."
2617+-- >>> splitWithSuffix' (== '.') "."
2618-- ["."]
2618-- ["."]
2619--
2619--
2620−-- >>> splitBySuffix' (== '.') "a"
2620+-- >>> splitWithSuffix' (== '.') "a"
2621-- ["a"]
2621-- ["a"]
2622--
2622--
2623−-- >>> splitBySuffix' (== '.') ".a"
2623+-- >>> splitWithSuffix' (== '.') ".a"
2624-- > [".","a"]
2624-- > [".","a"]
2625--
2625--
2626−-- >>> splitBySuffix' (== '.') "a."
2626+-- >>> splitWithSuffix' (== '.') "a."
2627-- > ["a."]
2627-- > ["a."]
2628--
2628--
2629−-- >>> splitBySuffix' (== '.') "a.b"
2629+-- >>> splitWithSuffix' (== '.') "a.b"
2630-- > ["a.","b"]
2630-- > ["a.","b"]
2631--
2631--
2632−-- >>> splitBySuffix' (== '.') "a.b."
2632+-- >>> splitWithSuffix' (== '.') "a.b."
2633-- > ["a.","b."]
2633-- > ["a.","b."]
2634--
2634--
2635−-- >>> splitBySuffix' (== '.') "a..b.."
2635+-- >>> splitWithSuffix' (== '.') "a..b.."
2636-- > ["a.",".","b.","."]
2636-- > ["a.",".","b.","."]
2637--
2637--
2638-- @since 0.7.0
2638-- @since 0.7.0
@@ -2640,11 +2640,11 @@ wordsBy predicate f m =
2640-- This can be considered as an n-fold version of 'breakPost' where we apply
2640-- This can be considered as an n-fold version of 'breakPost' where we apply
2641-- 'breakPost' successively on the input stream.
2641-- 'breakPost' successively on the input stream.
2642--
2642--
2643−{-# INLINE splitBySuffix #-}
2643+{-# INLINE splitWithSuffix #-}
2644−splitBySuffix
2644+splitWithSuffix
2645 :: (IsStream t, Monad m)
2645 :: (IsStream t, Monad m)
2646 => (a -> Bool) -> Fold m a b -> t m a -> t m b
2646 => (a -> Bool) -> Fold m a b -> t m a -> t m b
2647−splitBySuffix predicate f m =
2647+splitWithSuffix predicate f m =
2648 D.fromStreamD $ D.splitSuffixBy' predicate f (D.toStreamD m)
2648 D.fromStreamD $ D.splitSuffixBy' predicate f (D.toStreamD m)
2649
2649
2650------------------------------------------------------------------------------
2650------------------------------------------------------------------------------
@@ -2863,11 +2863,11 @@ splitBySeq patt f m = intersperseM (runFold f (A.read patt)) $ splitOnSeq patt f
2863-- > ["a.",".","b.","."]
2863-- > ["a.",".","b.","."]
2864--
2864--
2865-- @since 0.7.0
2865-- @since 0.7.0
2866−{-# INLINE splitBySuffixSeq #-}
2866+{-# INLINE splitWithSuffixSeq #-}
2867−splitBySuffixSeq
2867+splitWithSuffixSeq
2868 :: (IsStream t, MonadIO m, Storable a, Enum a, Eq a)
2868 :: (IsStream t, MonadIO m, Storable a, Enum a, Eq a)
2869 => Array a -> Fold m a b -> t m a -> t m b
2869 => Array a -> Fold m a b -> t m a -> t m b
2870−splitBySuffixSeq patt f m =
2870+splitWithSuffixSeq patt f m =
2871 D.fromStreamD $ D.splitSuffixOn True patt f (D.toStreamD m)
2871 D.fromStreamD $ D.splitSuffixOn True patt f (D.toStreamD m)
2872
2872
2873{-
2873{-