on master help sign in
Rename serialWith to splitWith
0d3c63aAdithya Kumar
benchmark/Streamly/Benchmark/Data/Fold.hs+2−2
@@ -121,7 +121,7 @@ many = Stream.fold (FL.many (FL.take 1 FL.drain) FL.drain)
121splitAllAny :: Monad m => Int -> Stream m Int -> m (Bool, Bool)
121splitAllAny :: Monad m => Int -> Stream m Int -> m (Bool, Bool)
122splitAllAny value =
122splitAllAny value =
123 Stream.fold
123 Stream.fold
124− (FL.serialWith (,)
124+ (FL.splitWith (,)
125 (FL.all (<= (value `div` 2)))
125 (FL.all (<= (value `div` 2)))
126 (FL.any (> value))
126 (FL.any (> value))
127 )
127 )
@@ -399,7 +399,7 @@ o_1_space_serial_composition value =
399 , benchIOSink value "scanMaybe even" $ scanMaybe value
399 , benchIOSink value "scanMaybe even" $ scanMaybe value
400 , benchIOSink value "scanMaybe even, odd" $ scanMaybe2 value
400 , benchIOSink value "scanMaybe even, odd" $ scanMaybe2 value
401 , benchIOSink value "foldBreak (recursive)" foldBreak
401 , benchIOSink value "foldBreak (recursive)" foldBreak
402− , benchIOSink value "serialWith (all, any)" $ splitAllAny value
402+ , benchIOSink value "splitWith (all, any)" $ splitAllAny value
403 , benchIOSink value "serial_ (all, any)" $ serial_ value
403 , benchIOSink value "serial_ (all, any)" $ serial_ value
404 , benchIOSink value "tee (all, any)" $ teeAllAny value
404 , benchIOSink value "tee (all, any)" $ teeAllAny value
405 , benchIOSink value "many drain (take 1)" many
405 , benchIOSink value "many drain (take 1)" many
benchmark/Streamly/Benchmark/Data/Parser.hs+5−5
@@ -260,12 +260,12 @@ splitApAfter value =
260 <* PR.dropWhile (<= value)
260 <* PR.dropWhile (<= value)
261 )
261 )
262
262
263−{-# INLINE serialWith #-}
263+{-# INLINE splitWith #-}
264−serialWith :: MonadThrow m
264+splitWith :: MonadThrow m
265 => Int -> Stream m Int -> m ((), ())
265 => Int -> Stream m Int -> m ((), ())
266−serialWith value =
266+splitWith value =
267 Stream.parse
267 Stream.parse
268− (PR.serialWith (,)
268+ (PR.splitWith (,)
269 (PR.dropWhile (<= (value `div` 2)))
269 (PR.dropWhile (<= (value `div` 2)))
270 (PR.dropWhile (<= value))
270 (PR.dropWhile (<= value))
271 )
271 )
@@ -463,7 +463,7 @@ o_1_space_serial value =
463 , benchIOSink value "splitAp" $ splitAp value
463 , benchIOSink value "splitAp" $ splitAp value
464 , benchIOSink value "splitApBefore" $ splitApBefore value
464 , benchIOSink value "splitApBefore" $ splitApBefore value
465 , benchIOSink value "splitApAfter" $ splitApAfter value
465 , benchIOSink value "splitApAfter" $ splitApAfter value
466− , benchIOSink value "serialWith" $ serialWith value
466+ , benchIOSink value "splitWith" $ splitWith value
467 , benchIOSink value "takeEndBy_" $ takeEndBy_ value
467 , benchIOSink value "takeEndBy_" $ takeEndBy_ value
468 , benchIOSink value "many" many
468 , benchIOSink value "many" many
469 , benchIOSink value "many (wordBy even)" $ manyWordByEven
469 , benchIOSink value "many (wordBy even)" $ manyWordByEven
benchmark/Streamly/Benchmark/Data/Parser/ParserD.hs+4−4
@@ -147,10 +147,10 @@ manyTill value =
147 pcond = PR.satisfy (== value)
147 pcond = PR.satisfy (== value)
148 in Stream.parseD (PR.manyTill p pcond Fold.length)
148 in Stream.parseD (PR.manyTill p pcond Fold.length)
149
149
150−{-# INLINE serialWith #-}
150+{-# INLINE splitWith #-}
151−serialWith :: MonadThrow m
151+splitWith :: MonadThrow m
152 => Int -> Stream m Int -> m ((), ())
152 => Int -> Stream m Int -> m ((), ())
153−serialWith value =
153+splitWith value =
154 Stream.parseD
154 Stream.parseD
155 ((,)
155 ((,)
156 <$> drainWhile (<= (value `div` 2))
156 <$> drainWhile (<= (value `div` 2))
@@ -348,7 +348,7 @@ o_1_space_serial value =
348 , benchIOSink value "groupBy" $ groupBy
348 , benchIOSink value "groupBy" $ groupBy
349 , benchIOSink value "groupByRolling" $ groupByRolling
349 , benchIOSink value "groupByRolling" $ groupByRolling
350 , benchIOSink value "wordBy" $ wordBy value
350 , benchIOSink value "wordBy" $ wordBy value
351− , benchIOSink value "serialWith" $ serialWith value
351+ , benchIOSink value "splitWith" $ splitWith value
352 , benchIOSink value "many" many
352 , benchIOSink value "many" many
353 , benchIOSink value "many (wordBy even)" $ manyWordByEven
353 , benchIOSink value "many (wordBy even)" $ manyWordByEven
354 , benchIOSink value "some" some
354 , benchIOSink value "some" some
core/src/Streamly/Data/Fold.hs+9−3
@@ -70,7 +70,7 @@
70-- first fold consumes the input until it terminates and the second fold
70-- first fold consumes the input until it terminates and the second fold
71-- consumes the rest of the input until it terminates:
71-- consumes the rest of the input until it terminates:
72--
72--
73−-- >>> f = Fold.serialWith (,) (Fold.take 8 Fold.toList) (Fold.takeEndBy (== '\n') Fold.toList)
73+-- >>> f = Fold.splitWith (,) (Fold.take 8 Fold.toList) (Fold.takeEndBy (== '\n') Fold.toList)
74-- >>> Stream.fold f $ Stream.fromList "header: hello\n"
74-- >>> Stream.fold f $ Stream.fromList "header: hello\n"
75-- ("header: ","hello\n")
75-- ("header: ","hello\n")
76--
76--
@@ -94,7 +94,7 @@
94-- We can often use streams or folds to achieve the same goal. However, streams
94-- We can often use streams or folds to achieve the same goal. However, streams
95-- are more efficient in composition of producers (e.g.
95-- are more efficient in composition of producers (e.g.
96-- 'Data.Stream.append' or 'Data.Stream.mergeBy') whereas folds are
96-- 'Data.Stream.append' or 'Data.Stream.mergeBy') whereas folds are
97−-- more efficient in composition of consumers (e.g. 'serialWith', 'partition'
97+-- more efficient in composition of consumers (e.g. 'splitWith', 'partition'
98-- or 'teeWith').
98-- or 'teeWith').
99--
99--
100-- Streams are producers, transformations on streams happen on the output side:
100-- Streams are producers, transformations on streams happen on the output side:
@@ -265,7 +265,7 @@ module Streamly.Data.Fold
265 , takeEndBy
265 , takeEndBy
266
266
267 -- ** Serial Append
267 -- ** Serial Append
268− , serialWith
268+ , splitWith
269
269
270 -- ** Parallel Distribution
270 -- ** Parallel Distribution
271 -- | For applicative composition using distribution see
271 -- | For applicative composition using distribution see
@@ -307,6 +307,7 @@ module Streamly.Data.Fold
307 , mapM
307 , mapM
308 , variance
308 , variance
309 , stdDev
309 , stdDev
310+ , serialWith
310 )
311 )
311where
312where
312
313
@@ -320,6 +321,11 @@ import Prelude
320
321
321import Streamly.Internal.Data.Fold
322import Streamly.Internal.Data.Fold
322
323
324+{-# DEPRECATED serialWith "Please use \"splitWith\" instead" #-}
325+{-# INLINE serialWith #-}
326+serialWith :: Monad m => (a -> b -> c) -> Fold m x a -> Fold m x b -> Fold m x c
327+serialWith = splitWith
328+
323-- $setup
329-- $setup
324-- >>> import Data.Function ((&))
330-- >>> import Data.Function ((&))
325-- >>> import qualified Streamly.Data.Fold as Fold
331-- >>> import qualified Streamly.Data.Fold as Fold
core/src/Streamly/Internal/Data/Array/Fold.hs+7−7
@@ -44,7 +44,7 @@ module Streamly.Internal.Data.Array.Fold
44 -- * Applicative
44 -- * Applicative
45 , fromPure
45 , fromPure
46 , fromEffect
46 , fromEffect
47− , serialWith
47+ , splitWith
48
48
49 -- * Monad
49 -- * Monad
50 , concatMap
50 , concatMap
@@ -255,20 +255,20 @@ serial_ (ArrayFold p1) (ArrayFold p2) =
255-- results using the supplied function.
255-- results using the supplied function.
256--
256--
257-- /Pre-release/
257-- /Pre-release/
258−{-# INLINE serialWith #-}
258+{-# INLINE splitWith #-}
259−serialWith :: MonadThrow m
259+splitWith :: MonadThrow m
260 => (a -> b -> c) -> ArrayFold m x a -> ArrayFold m x b -> ArrayFold m x c
260 => (a -> b -> c) -> ArrayFold m x a -> ArrayFold m x b -> ArrayFold m x c
261−serialWith f (ArrayFold p1) (ArrayFold p2) =
261+splitWith f (ArrayFold p1) (ArrayFold p2) =
262 ArrayFold $ ParserD.noErrorUnsafeSplitWith f p1 p2
262 ArrayFold $ ParserD.noErrorUnsafeSplitWith f p1 p2
263
263
264−-- | 'Applicative' form of 'serialWith'.
264+-- | 'Applicative' form of 'splitWith'.
265−-- > (<*>) = serialWith id
265+-- > (<*>) = splitWith id
266instance MonadThrow m => Applicative (ArrayFold m a) where
266instance MonadThrow m => Applicative (ArrayFold m a) where
267 {-# INLINE pure #-}
267 {-# INLINE pure #-}
268 pure = fromPure
268 pure = fromPure
269
269
270 {-# INLINE (<*>) #-}
270 {-# INLINE (<*>) #-}
271− (<*>) = serialWith id
271+ (<*>) = splitWith id
272
272
273 {-# INLINE (*>) #-}
273 {-# INLINE (*>) #-}
274 (*>) = serial_
274 (*>) = serial_
core/src/Streamly/Internal/Data/Fold.hs+3−3
@@ -237,7 +237,7 @@ module Streamly.Internal.Data.Fold
237 -}
237 -}
238
238
239 -- ** Serial Append
239 -- ** Serial Append
240− , serialWith
240+ , splitWith
241 , serial_
241 , serial_
242 -- , tail
242 -- , tail
243 -- , init
243 -- , init
@@ -1464,7 +1464,7 @@ or = any (== True)
1464-- >>> splitAt_ 4 [1,2,3]
1464-- >>> splitAt_ 4 [1,2,3]
1465-- ([1,2,3],[])
1465-- ([1,2,3],[])
1466--
1466--
1467−-- > splitAt n f1 f2 = Fold.serialWith (,) (Fold.take n f1) f2
1467+-- > splitAt n f1 f2 = Fold.splitWith (,) (Fold.take n f1) f2
1468--
1468--
1469-- /Internal/
1469-- /Internal/
1470
1470
@@ -1475,7 +1475,7 @@ splitAt
1475 -> Fold m a b
1475 -> Fold m a b
1476 -> Fold m a c
1476 -> Fold m a c
1477 -> Fold m a (b, c)
1477 -> Fold m a (b, c)
1478−splitAt n fld = serialWith (,) (take n fld)
1478+splitAt n fld = splitWith (,) (take n fld)
1479
1479
1480------------------------------------------------------------------------------
1480------------------------------------------------------------------------------
1481-- Element Aware APIs
1481-- Element Aware APIs
core/src/Streamly/Internal/Data/Fold/Type.hs+6−6
@@ -375,7 +375,7 @@ module Streamly.Internal.Data.Fold.Type
375 , dropping
375 , dropping
376
376
377 -- ** Sequential application
377 -- ** Sequential application
378− , serialWith -- rename to "append"
378+ , splitWith -- rename to "append"
379 , serial_
379 , serial_
380
380
381 -- ** Repeated Application (Splitting)
381 -- ** Repeated Application (Splitting)
@@ -758,7 +758,7 @@ data SeqFoldState sl f sr = SeqFoldL !sl | SeqFoldR !f !sr
758--
758--
759-- >>> header = Fold.take 8 Fold.toList
759-- >>> header = Fold.take 8 Fold.toList
760-- >>> line = Fold.takeEndBy (== '\n') Fold.toList
760-- >>> line = Fold.takeEndBy (== '\n') Fold.toList
761−-- >>> f = Fold.serialWith (,) header line
761+-- >>> f = Fold.splitWith (,) header line
762-- >>> Stream.fold f $ Stream.fromList "header: hello\n"
762-- >>> Stream.fold f $ Stream.fromList "header: hello\n"
763-- ("header: ","hello\n")
763-- ("header: ","hello\n")
764--
764--
@@ -773,10 +773,10 @@ data SeqFoldState sl f sr = SeqFoldL !sl | SeqFoldR !f !sr
773--
773--
774-- /Time: O(n^2) where n is the number of compositions./
774-- /Time: O(n^2) where n is the number of compositions./
775--
775--
776−{-# INLINE serialWith #-}
776+{-# INLINE splitWith #-}
777−serialWith :: Monad m =>
777+splitWith :: Monad m =>
778 (a -> b -> c) -> Fold m x a -> Fold m x b -> Fold m x c
778 (a -> b -> c) -> Fold m x a -> Fold m x b -> Fold m x c
779−serialWith func (Fold stepL initialL extractL) (Fold stepR initialR extractR) =
779+splitWith func (Fold stepL initialL extractL) (Fold stepR initialR extractR) =
780 Fold step initial extract
780 Fold step initial extract
781
781
782 where
782 where
@@ -810,7 +810,7 @@ data SeqFoldState_ sl sr = SeqFoldL_ !sl | SeqFoldR_ !sr
810-- discarding the result of the first.
810-- discarding the result of the first.
811--
811--
812-- This was written in the hope that it might be faster than implementing it
812-- This was written in the hope that it might be faster than implementing it
813−-- using serialWith, but the current benchmarks show that it has the same
813+-- using splitWith, but the current benchmarks show that it has the same
814-- performance. So do not expose it unless some benchmark shows benefit.
814-- performance. So do not expose it unless some benchmark shows benefit.
815--
815--
816{-# INLINE serial_ #-}
816{-# INLINE serial_ #-}
core/src/Streamly/Internal/Data/Parser.hs+10−10
@@ -150,7 +150,7 @@ module Streamly.Internal.Data.Parser
150 -- * Binary Combinators
150 -- * Binary Combinators
151
151
152 -- ** Sequential Applicative
152 -- ** Sequential Applicative
153− , serialWith
153+ , splitWith
154 , split_
154 , split_
155
155
156{-
156{-
@@ -1083,7 +1083,7 @@ regexPCRE = undefined
1083-- This implementation is strict in the second argument, therefore, the
1083-- This implementation is strict in the second argument, therefore, the
1084-- following will fail:
1084-- following will fail:
1085--
1085--
1086−-- >>> Stream.parse (Parser.serialWith const (Parser.satisfy (> 0)) undefined) $ Stream.fromList [1]
1086+-- >>> Stream.parse (Parser.splitWith const (Parser.satisfy (> 0)) undefined) $ Stream.fromList [1]
1087-- *** Exception: Prelude.undefined
1087-- *** Exception: Prelude.undefined
1088-- ...
1088-- ...
1089--
1089--
@@ -1092,31 +1092,31 @@ regexPCRE = undefined
1092-- operations and can be faster than 'Applicative' instance for small number
1092-- operations and can be faster than 'Applicative' instance for small number
1093-- (less than 8) of compositions.
1093-- (less than 8) of compositions.
1094--
1094--
1095−-- Many combinators can be expressed using @serialWith@ and other parser
1095+-- Many combinators can be expressed using @splitWith@ and other parser
1096-- primitives. Some common idioms are described below,
1096-- primitives. Some common idioms are described below,
1097--
1097--
1098-- @
1098-- @
1099-- span :: (a -> Bool) -> Fold m a b -> Fold m a b -> Parser a m b
1099-- span :: (a -> Bool) -> Fold m a b -> Fold m a b -> Parser a m b
1100−-- span pred f1 f2 = serialWith (,) ('takeWhile' pred f1) ('fromFold' f2)
1100+-- span pred f1 f2 = splitWith (,) ('takeWhile' pred f1) ('fromFold' f2)
1101-- @
1101-- @
1102--
1102--
1103-- @
1103-- @
1104-- spanBy :: (a -> a -> Bool) -> Fold m a b -> Fold m a b -> Parser a m b
1104-- spanBy :: (a -> a -> Bool) -> Fold m a b -> Fold m a b -> Parser a m b
1105−-- spanBy eq f1 f2 = serialWith (,) ('groupBy' eq f1) ('fromFold' f2)
1105+-- spanBy eq f1 f2 = splitWith (,) ('groupBy' eq f1) ('fromFold' f2)
1106-- @
1106-- @
1107--
1107--
1108-- @
1108-- @
1109-- spanByRolling :: (a -> a -> Bool) -> Fold m a b -> Fold m a b -> Parser a m b
1109-- spanByRolling :: (a -> a -> Bool) -> Fold m a b -> Fold m a b -> Parser a m b
1110−-- spanByRolling eq f1 f2 = serialWith (,) ('groupByRolling' eq f1) ('fromFold' f2)
1110+-- spanByRolling eq f1 f2 = splitWith (,) ('groupByRolling' eq f1) ('fromFold' f2)
1111-- @
1111-- @
1112--
1112--
1113-- /Pre-release/
1113-- /Pre-release/
1114--
1114--
1115−{-# INLINE serialWith #-}
1115+{-# INLINE splitWith #-}
1116−serialWith :: Monad m
1116+splitWith :: Monad m
1117 => (a -> b -> c) -> Parser x m a -> Parser x m b -> Parser x m c
1117 => (a -> b -> c) -> Parser x m a -> Parser x m b -> Parser x m c
1118−serialWith f p1 p2 =
1118+splitWith f p1 p2 =
1119− D.toParserK $ D.serialWith f (D.fromParserK p1) (D.fromParserK p2)
1119+ D.toParserK $ D.splitWith f (D.fromParserK p1) (D.fromParserK p2)
1120
1120
1121-- | Sequential parser application ignoring the output of the first parser.
1121-- | Sequential parser application ignoring the output of the first parser.
1122-- Apply two parsers sequentially to an input stream. The input is provided to
1122-- Apply two parsers sequentially to an input stream. The input is provided to
core/src/Streamly/Internal/Data/Parser/ParserD.hs+1−1
@@ -106,7 +106,7 @@ module Streamly.Internal.Data.Parser.ParserD
106 -- * Binary Combinators
106 -- * Binary Combinators
107
107
108 -- ** Sequential Applicative
108 -- ** Sequential Applicative
109− , serialWith
109+ , splitWith
110 , split_
110 , split_
111
111
112 {-
112 {-
core/src/Streamly/Internal/Data/Parser/ParserD/Type.hs+10−10
@@ -183,7 +183,7 @@ module Streamly.Internal.Data.Parser.ParserD.Type
183
183
184 , fromPure
184 , fromPure
185 , fromEffect
185 , fromEffect
186− , serialWith
186+ , splitWith
187 , split_
187 , split_
188
188
189 , die
189 , die
@@ -671,9 +671,9 @@ fromEffect b = Parser undefined (IDone <$> b) undefined
671{-# ANN type SeqParseState Fuse #-}
671{-# ANN type SeqParseState Fuse #-}
672data SeqParseState sl f sr = SeqParseL sl | SeqParseR f sr
672data SeqParseState sl f sr = SeqParseL sl | SeqParseR f sr
673
673
674−-- | See 'Streamly.Internal.Data.Parser.serialWith'.
674+-- | See 'Streamly.Internal.Data.Parser.splitWith'.
675--
675--
676−-- Note: this implementation of serialWith is fast because of stream fusion but
676+-- Note: this implementation of splitWith is fast because of stream fusion but
677-- has quadratic time complexity, because each composition adds a new branch
677-- has quadratic time complexity, because each composition adds a new branch
678-- that each subsequent parse's input element has to go through, therefore, it
678-- that each subsequent parse's input element has to go through, therefore, it
679-- cannot scale to a large number of compositions. After around 100
679-- cannot scale to a large number of compositions. After around 100
@@ -682,10 +682,10 @@ data SeqParseState sl f sr = SeqParseL sl | SeqParseR f sr
682--
682--
683-- /Pre-release/
683-- /Pre-release/
684--
684--
685−{-# INLINE serialWith #-}
685+{-# INLINE splitWith #-}
686−serialWith :: Monad m
686+splitWith :: Monad m
687 => (a -> b -> c) -> Parser x m a -> Parser x m b -> Parser x m c
687 => (a -> b -> c) -> Parser x m a -> Parser x m b -> Parser x m c
688−serialWith func (Parser stepL initialL extractL)
688+splitWith func (Parser stepL initialL extractL)
689 (Parser stepR initialR extractR) =
689 (Parser stepR initialR extractR) =
690 Parser step initial extract
690 Parser step initial extract
691
691
@@ -748,7 +748,7 @@ serialWith func (Parser stepL initialL extractL)
748 IDone bR -> return $ Done n $ func bL bR
748 IDone bR -> return $ Done n $ func bL bR
749 IError err -> return $ Error err
749 IError err -> return $ Error err
750 Error err -> return $ Error err
750 Error err -> return $ Error err
751− Partial _ _ -> error "Bug: serialWith extract 'Partial'"
751+ Partial _ _ -> error "Bug: splitWith extract 'Partial'"
752 Continue n s -> return $ Continue n (SeqParseL s)
752 Continue n s -> return $ Continue n (SeqParseL s)
753
753
754-------------------------------------------------------------------------------
754-------------------------------------------------------------------------------
@@ -827,7 +827,7 @@ noErrorUnsafeSplitWith func (Parser stepL initialL extractL)
827{-# ANN type SeqAState Fuse #-}
827{-# ANN type SeqAState Fuse #-}
828data SeqAState sl sr = SeqAL sl | SeqAR sr
828data SeqAState sl sr = SeqAL sl | SeqAR sr
829
829
830−-- This turns out to be slightly faster than serialWith
830+-- This turns out to be slightly faster than splitWith
831-- | See 'Streamly.Internal.Data.Parser.split_'.
831-- | See 'Streamly.Internal.Data.Parser.split_'.
832--
832--
833-- /Pre-release/
833-- /Pre-release/
@@ -940,13 +940,13 @@ noErrorUnsafeSplit_
940 Partial _ _ -> error "split_: Partial"
940 Partial _ _ -> error "split_: Partial"
941 Continue n s -> return $ Continue n (SeqAL s)
941 Continue n s -> return $ Continue n (SeqAL s)
942
942
943−-- | 'Applicative' form of 'serialWith'.
943+-- | 'Applicative' form of 'splitWith'.
944instance Monad m => Applicative (Parser a m) where
944instance Monad m => Applicative (Parser a m) where
945 {-# INLINE pure #-}
945 {-# INLINE pure #-}
946 pure = fromPure
946 pure = fromPure
947
947
948 {-# INLINE (<*>) #-}
948 {-# INLINE (<*>) #-}
949− (<*>) = serialWith id
949+ (<*>) = splitWith id
950
950
951 {-# INLINE (*>) #-}
951 {-# INLINE (*>) #-}
952 (*>) = split_
952 (*>) = split_
core/src/Streamly/Internal/Data/Parser/ParserK/Type.hs+2−2
@@ -139,8 +139,8 @@ fromPure b = MkParser $ \n st k -> k st (Success n b)
139fromEffect :: Monad m => m b -> Parser a m b
139fromEffect :: Monad m => m b -> Parser a m b
140fromEffect eff = MkParser $ \n st k -> eff >>= \b -> k st (Success n b)
140fromEffect eff = MkParser $ \n st k -> eff >>= \b -> k st (Success n b)
141
141
142−-- | 'Applicative' form of 'Streamly.Internal.Data.Parser.serialWith'. Note that
142+-- | 'Applicative' form of 'Streamly.Internal.Data.Parser.splitWith'. Note that
143−-- this operation does not fuse, use 'Streamly.Internal.Data.Parser.serialWith'
143+-- this operation does not fuse, use 'Streamly.Internal.Data.Parser.splitWith'
144-- when fusion is important.
144-- when fusion is important.
145--
145--
146instance Monad m => Applicative (Parser a m) where
146instance Monad m => Applicative (Parser a m) where
docs/User/ProjectRelated/Changelog.md+1
@@ -25,6 +25,7 @@
25* In `Streamly.Data.Fold`:
25* In `Streamly.Data.Fold`:
26 * `variance`, and `stdDev` have been deprecated. Please use the
26 * `variance`, and `stdDev` have been deprecated. Please use the
27 `streamly-statistics` package instead.
27 `streamly-statistics` package instead.
28+ * `serialWith` is deprecated. Use `splitWith` instead.
28* `Streamly.Data.Array.Foreign` is deprecated. Use `Streamly.Data.Array`
29* `Streamly.Data.Array.Foreign` is deprecated. Use `Streamly.Data.Array`
29 instead.
30 instead.
30* The type of `replicateM` in `Streamly.Data.Unfold` is changed.
31* The type of `replicateM` in `Streamly.Data.Unfold` is changed.
test/Streamly/Test/Data/Fold.hs+1−1
@@ -784,7 +784,7 @@ main = hspec $ do
784 prop "takeEndByOrMax" takeEndByOrMax
784 prop "takeEndByOrMax" takeEndByOrMax
785
785
786 -- Appending
786 -- Appending
787− -- serialWith
787+ -- splitWith
788
788
789 -- Distributing
789 -- Distributing
790 -- tee
790 -- tee
test/Streamly/Test/Data/Parser.hs+4−4
@@ -537,7 +537,7 @@ parseManyWordQuotedBy =
537-- splitWithPass :: Property
537-- splitWithPass :: Property
538-- splitWithPass =
538-- splitWithPass =
539-- forAll (listOf (chooseInt (0, 1))) $ \ls ->
539-- forAll (listOf (chooseInt (0, 1))) $ \ls ->
540−-- case S.parse (P.serialWith (,) (P.satisfy (== 0)) (P.satisfy (== 1))) (S.fromList ls) of
540+-- case S.parse (P.splitWith (,) (P.satisfy (== 0)) (P.satisfy (== 1))) (S.fromList ls) of
541-- Right (result_first, result_second) -> case ls of
541-- Right (result_first, result_second) -> case ls of
542-- 0 : 1 : _ -> (result_first == 0) && (result_second == 1)
542-- 0 : 1 : _ -> (result_first == 0) && (result_second == 1)
543-- _ -> False
543-- _ -> False
@@ -547,19 +547,19 @@ parseManyWordQuotedBy =
547
547
548-- splitWithFailLeft :: Property
548-- splitWithFailLeft :: Property
549-- splitWithFailLeft =
549-- splitWithFailLeft =
550−-- property (case S.parse (P.serialWith (,) (P.die "die") (P.fromPure (1 :: Int))) (S.fromList [1 :: Int]) of
550+-- property (case S.parse (P.splitWith (,) (P.die "die") (P.fromPure (1 :: Int))) (S.fromList [1 :: Int]) of
551-- Right _ -> False
551-- Right _ -> False
552-- Left _ -> True)
552-- Left _ -> True)
553
553
554-- splitWithFailRight :: Property
554-- splitWithFailRight :: Property
555-- splitWithFailRight =
555-- splitWithFailRight =
556−-- property (case S.parse (P.serialWith (,) (P.fromPure (1 :: Int)) (P.die "die")) (S.fromList [1 :: Int]) of
556+-- property (case S.parse (P.splitWith (,) (P.fromPure (1 :: Int)) (P.die "die")) (S.fromList [1 :: Int]) of
557-- Right _ -> False
557-- Right _ -> False
558-- Left _ -> True)
558-- Left _ -> True)
559
559
560-- splitWithFailBoth :: Property
560-- splitWithFailBoth :: Property
561-- splitWithFailBoth =
561-- splitWithFailBoth =
562−-- property (case S.parse (P.serialWith (,) (P.die "die") (P.die "die")) (S.fromList [1 :: Int]) of
562+-- property (case S.parse (P.splitWith (,) (P.die "die") (P.die "die")) (S.fromList [1 :: Int]) of
563-- Right _ -> False
563-- Right _ -> False
564-- Left _ -> True)
564-- Left _ -> True)
565
565
test/Streamly/Test/Data/Parser/ParserD.hs+7−7
@@ -392,10 +392,10 @@ wordBy =
392 in if wrds == [] && length lst > 0 then [""] else wrds
392 in if wrds == [] && length lst > 0 then [""] else wrds
393
393
394
394
395−serialWith :: Property
395+splitWith :: Property
396−serialWith =
396+splitWith =
397 forAll (listOf (chooseInt (0, 1))) $ \ls ->
397 forAll (listOf (chooseInt (0, 1))) $ \ls ->
398− case S.parseD (P.serialWith (,) (P.satisfy (== 0)) (P.satisfy (== 1))) (S.fromList ls) of
398+ case S.parseD (P.splitWith (,) (P.satisfy (== 0)) (P.satisfy (== 1))) (S.fromList ls) of
399 Right (result_first, result_second) -> case ls of
399 Right (result_first, result_second) -> case ls of
400 0 : 1 : _ -> (result_first == 0) && (result_second == 1)
400 0 : 1 : _ -> (result_first == 0) && (result_second == 1)
401 _ -> False
401 _ -> False
@@ -405,19 +405,19 @@ serialWith =
405
405
406splitWithFailLeft :: Property
406splitWithFailLeft :: Property
407splitWithFailLeft =
407splitWithFailLeft =
408− property (case S.parseD (P.serialWith (,) (P.die "die") (P.fromPure (1 :: Int))) (S.fromList [1 :: Int]) of
408+ property (case S.parseD (P.splitWith (,) (P.die "die") (P.fromPure (1 :: Int))) (S.fromList [1 :: Int]) of
409 Right _ -> False
409 Right _ -> False
410 Left _ -> True)
410 Left _ -> True)
411
411
412splitWithFailRight :: Property
412splitWithFailRight :: Property
413splitWithFailRight =
413splitWithFailRight =
414− property (case S.parseD (P.serialWith (,) (P.fromPure (1 :: Int)) (P.die "die")) (S.fromList [1 :: Int]) of
414+ property (case S.parseD (P.splitWith (,) (P.fromPure (1 :: Int)) (P.die "die")) (S.fromList [1 :: Int]) of
415 Right _ -> False
415 Right _ -> False
416 Left _ -> True)
416 Left _ -> True)
417
417
418splitWithFailBoth :: Property
418splitWithFailBoth :: Property
419splitWithFailBoth =
419splitWithFailBoth =
420− property (case S.parseD (P.serialWith (,) (P.die "die") (P.die "die")) (S.fromList [1 :: Int]) of
420+ property (case S.parseD (P.splitWith (,) (P.die "die") (P.die "die")) (S.fromList [1 :: Int]) of
421 Right _ -> False
421 Right _ -> False
422 Left _ -> True)
422 Left _ -> True)
423
423
@@ -794,7 +794,7 @@ main =
794 prop "groupByRolling" groupByRolling
794 prop "groupByRolling" groupByRolling
795 prop "P.takeEndByOrMax = Prelude.take n (Prelude.takeWhile (not . predicate)" takeEndByOrMax
795 prop "P.takeEndByOrMax = Prelude.take n (Prelude.takeWhile (not . predicate)" takeEndByOrMax
796 prop "many (P.wordBy ' ') = words'" wordBy
796 prop "many (P.wordBy ' ') = words'" wordBy
797− prop "parse 0, then 1, else fail" serialWith
797+ prop "parse 0, then 1, else fail" splitWith
798 prop "fail due to die as left parser" splitWithFailLeft
798 prop "fail due to die as left parser" splitWithFailLeft
799 prop "fail due to die as right parser" splitWithFailRight
799 prop "fail due to die as right parser" splitWithFailRight
800 prop "fail due to die as both parsers" splitWithFailBoth
800 prop "fail due to die as both parsers" splitWithFailBoth