on master help sign in
Split Serial module into Serial and WSerial
commit5ddfb4576482b2ec712fffa0771b114c3e821958 authorHarendra Kumar <harendra@composewell.com> dateWed 23 Mar 2022, 01:33 (5 years ago) parent5a10fb9
8 files changed+265−206
core/src/Streamly/Internal/Data/Stream/Serial.hs+1−195 core/src/Streamly/Internal/Data/Stream/WSerial.hs+249 core/streamly-core.cabal+1 src/Streamly/Internal/Data/Stream/IsStream/Expand.hs+4−4 src/Streamly/Internal/Data/Stream/IsStream/Generate.hs+2−1 src/Streamly/Internal/Data/Stream/IsStream/Type.hs+5−4 streamly.cabal+1 test/Streamly/Test/Prelude/WSerial.hs+2−2
core/src/Streamly/Internal/Data/Stream/Serial.hs+1−195
@@ -21,15 +21,6 @@ module Streamly.Internal.Data.Stream.Serial
2121 , Serial
2222 , serial
2323
24− -- * Serial interleaving stream
25− , WSerialT(..)
26− , WSerial
27− , wSerialK
28− , wSerial
29− , wSerialFst
30− , wSerialMin
31− , consMWSerial
32−
3324 -- * Construction
3425 , cons
3526 , consM
@@ -72,8 +63,7 @@ import Text.Read
7263import Streamly.Internal.BaseCompat ((#.))
7364import Streamly.Internal.Data.Fold.Type (Fold)
7465import Streamly.Internal.Data.Maybe.Strict (Maybe'(..), toMaybe)
75−import Streamly.Internal.Data.Stream.StreamK.Type
76− (Stream, mkStream, foldStream)
66+import Streamly.Internal.Data.Stream.StreamK.Type (Stream)
7767
7868import qualified Streamly.Internal.Data.Stream.Common as P
7969import qualified Streamly.Internal.Data.Stream.StreamD.Generate as D
@@ -323,190 +313,6 @@ list = fromStreamD . D.fromList
323313{-# RULES "list fallback to StreamK" [1]
324314 forall a. D.toStreamK (D.fromList a) = K.fromFoldable a #-}
325315
326−------------------------------------------------------------------------------
327−-- WSerialT
328−------------------------------------------------------------------------------
329−
330−-- | For 'WSerialT' streams:
331−--
332−-- @
333−-- (<>) = 'Streamly.Prelude.wSerial' -- 'Semigroup'
334−-- (>>=) = flip . 'Streamly.Prelude.concatMapWith' 'Streamly.Prelude.wSerial' -- 'Monad'
335−-- @
336−--
337−-- Note that '<>' is associative only if we disregard the ordering of elements
338−-- in the resulting stream.
339−--
340−-- A single 'Monad' bind behaves like a @for@ loop:
341−--
342−-- >>> :{
343−-- Stream.toList $ Stream.fromWSerial $ do
344−-- x <- Stream.fromList [1,2] -- foreach x in stream
345−-- return x
346−-- :}
347−-- [1,2]
348−--
349−-- Nested monad binds behave like interleaved nested @for@ loops:
350−--
351−-- >>> :{
352−-- Stream.toList $ Stream.fromWSerial $ do
353−-- x <- Stream.fromList [1,2] -- foreach x in stream
354−-- y <- Stream.fromList [3,4] -- foreach y in stream
355−-- return (x, y)
356−-- :}
357−-- [(1,3),(2,3),(1,4),(2,4)]
358−--
359−-- It is a result of interleaving all the nested iterations corresponding to
360−-- element @1@ in the first stream with all the nested iterations of element
361−-- @2@:
362−--
363−-- >>> import Streamly.Prelude (wSerial)
364−-- >>> Stream.toList $ Stream.fromList [(1,3),(1,4)] `Stream.wSerial` Stream.fromList [(2,3),(2,4)]
365−-- [(1,3),(2,3),(1,4),(2,4)]
366−--
367−-- The @W@ in the name stands for @wide@ or breadth wise scheduling in
368−-- contrast to the depth wise scheduling behavior of 'SerialT'.
369−--
370−-- /Since: 0.2.0 ("Streamly")/
371−--
372−-- @since 0.8.0
373−newtype WSerialT m a = WSerialT {getWSerialT :: Stream m a}
374− deriving (MonadTrans)
375−
376−-- | An interleaving serial IO stream of elements of type @a@. See 'WSerialT'
377−-- documentation for more details.
378−--
379−-- /Since: 0.2.0 ("Streamly")/
380−--
381−-- @since 0.8.0
382−type WSerial = WSerialT IO
383−
384−{-# INLINE consMWSerial #-}
385−{-# SPECIALIZE consMWSerial :: IO a -> WSerialT IO a -> WSerialT IO a #-}
386−consMWSerial :: Monad m => m a -> WSerialT m a -> WSerialT m a
387−consMWSerial m (WSerialT ms) = WSerialT $ K.consM m ms
388−
389−------------------------------------------------------------------------------
390−-- Semigroup
391−------------------------------------------------------------------------------
392−
393−infixr 6 `wSerial`
394−
395−-- Additionally we can have m elements yield from the first stream and n
396−-- elements yielding from the second stream. We can also have time slicing
397−-- variants of positional interleaving, e.g. run first stream for m seconds and
398−-- run the second stream for n seconds.
399−--
400−-- Similar combinators can be implemented using WAhead style.
401−
402−{-# INLINE wSerialK #-}
403−wSerialK :: Stream m a -> Stream m a -> Stream m a
404−wSerialK m1 m2 = mkStream $ \st yld sng stp -> do
405− let stop = foldStream st yld sng stp m2
406− single a = yld a m2
407− yieldk a r = yld a (wSerialK m2 r)
408− foldStream st yieldk single stop m1
409−
410−-- | Interleaves two streams, yielding one element from each stream
411−-- alternately. When one stream stops the rest of the other stream is used in
412−-- the output stream.
413−
414−-- Scheduling Notes:
415−--
416−-- Note that evaluation of @a \`wSerial` b \`wSerial` c@ does not interleave
417−-- @a@, @b@ and @c@ with equal priority. This expression is equivalent to @a
418−-- \`wSerial` (b \`wSerial` c)@, therefore, it fairly interleaves @a@ with the
419−-- result of @b \`wSerial` c@. For example, @Stream.fromList [1,2] \`wSerial`
420−-- Stream.fromList [3,4] \`wSerial` Stream.fromList [5,6]@ would result in
421−-- [1,3,2,5,4,6]. In other words, the leftmost stream gets the same scheduling
422−-- priority as the rest of the streams taken together. The same is true for
423−-- each subexpression on the right.
424−--
425−{-# INLINE wSerial #-}
426−wSerial :: WSerialT m a -> WSerialT m a -> WSerialT m a
427−wSerial (WSerialT m1) (WSerialT m2) = WSerialT $ wSerialK m1 m2
428−
429−-- | Like `wSerial` but stops interleaving as soon as the first stream stops.
430−--
431−-- @since 0.7.0
432−{-# INLINE wSerialFstK #-}
433−wSerialFstK :: Stream m a -> Stream m a -> Stream m a
434−wSerialFstK m1 m2 = mkStream $ \st yld sng stp -> do
435− let yieldFirst a r = yld a (yieldSecond r m2)
436− in foldStream st yieldFirst sng stp m1
437−
438− where
439−
440− yieldSecond s1 s2 = mkStream $ \st yld sng stp -> do
441− let stop = foldStream st yld sng stp s1
442− single a = yld a s1
443− yieldk a r = yld a (wSerialK s1 r)
444− in foldStream st yieldk single stop s2
445−
446−{-# INLINE wSerialFst #-}
447−wSerialFst :: WSerialT m a -> WSerialT m a -> WSerialT m a
448−wSerialFst (WSerialT m1) (WSerialT m2) = WSerialT $ wSerialFstK m1 m2
449−
450−-- | Like `wSerial` but stops interleaving as soon as any of the two streams
451−-- stops.
452−--
453−-- @since 0.7.0
454−{-# INLINE wSerialMinK #-}
455−wSerialMinK :: Stream m a -> Stream m a -> Stream m a
456−wSerialMinK m1 m2 = mkStream $ \st yld _ stp -> do
457− let stop = stp
458− -- "single a" is defined as "yld a (wSerialMin m2 K.nil)" instead of
459− -- "sng a" to keep the behaviour consistent with the yield continuation.
460− single a = yld a (wSerialMinK m2 K.nil)
461− yieldk a r = yld a (wSerialMinK m2 r)
462− foldStream st yieldk single stop m1
463−
464−{-# INLINE wSerialMin #-}
465−wSerialMin :: WSerialT m a -> WSerialT m a -> WSerialT m a
466−wSerialMin (WSerialT m1) (WSerialT m2) = WSerialT $ wSerialMinK m1 m2
467−
468−instance Semigroup (WSerialT m a) where
469− (<>) = wSerial
470−
471−------------------------------------------------------------------------------
472−-- Monoid
473−------------------------------------------------------------------------------
474−
475−instance Monoid (WSerialT m a) where
476− mempty = WSerialT K.nil
477− mappend = (<>)
478−
479−{-# INLINE apWSerial #-}
480−apWSerial :: Monad m => WSerialT m (a -> b) -> WSerialT m a -> WSerialT m b
481−apWSerial (WSerialT m1) (WSerialT m2) =
482− let f x1 = K.concatMapWith wSerialK (pure . x1) m2
483− in WSerialT $ K.concatMapWith wSerialK f m1
484−
485−instance Monad m => Applicative (WSerialT m) where
486− {-# INLINE pure #-}
487− pure = WSerialT . K.fromPure
488− {-# INLINE (<*>) #-}
489− (<*>) = apWSerial
490−
491−------------------------------------------------------------------------------
492−-- Monad
493−------------------------------------------------------------------------------
494−
495−instance Monad m => Monad (WSerialT m) where
496− return = pure
497− {-# INLINE (>>=) #-}
498− (>>=) (WSerialT m) f = WSerialT $ K.bindWith wSerialK m (getWSerialT . f)
499−
500−------------------------------------------------------------------------------
501−-- Other instances
502−------------------------------------------------------------------------------
503−
504−MONAD_COMMON_INSTANCES(WSerialT,)
505−LIST_INSTANCES(WSerialT)
506−NFDATA1_INSTANCE(WSerialT)
507−FOLDABLE_INSTANCE(WSerialT)
508−TRAVERSABLE_INSTANCE(WSerialT)
509−
510316------------------------------------------------------------------------------
511317-- Construction
512318------------------------------------------------------------------------------
core/src/Streamly/Internal/Data/Stream/WSerial.hsnew file+249
@@ -0,0 +1,249 @@
1+{-# LANGUAGE UndecidableInstances #-}
2+
3+-- |
4+-- Module : Streamly.Internal.Data.Stream.WSerial
5+-- Copyright : (c) 2017 Composewell Technologies
6+--
7+-- License : BSD3
8+-- Maintainer : streamly@composewell.com
9+-- Stability : experimental
10+-- Portability : GHC
11+--
12+-- To run examples in this module:
13+--
14+-- >>> import qualified Streamly.Prelude as Stream
15+--
16+module Streamly.Internal.Data.Stream.WSerial
17+ (
18+ -- * Serial interleaving stream
19+ WSerialT(..)
20+ , WSerial
21+ , wSerialK
22+ , wSerial
23+ , wSerialFst
24+ , wSerialMin
25+ , consMWSerial
26+ )
27+where
28+
29+import Control.Applicative (liftA2)
30+import Control.DeepSeq (NFData(..))
31+import Control.DeepSeq (NFData1(..))
32+import Control.Monad.Base (MonadBase(..), liftBaseDefault)
33+import Control.Monad.Catch (MonadThrow, throwM)
34+import Control.Monad.IO.Class (MonadIO(..))
35+import Control.Monad.Reader.Class (MonadReader(..))
36+import Control.Monad.State.Class (MonadState(..))
37+import Control.Monad.Trans.Class (MonadTrans(lift))
38+import Data.Foldable (Foldable(foldl'), fold)
39+import Data.Functor.Identity (Identity(..), runIdentity)
40+import Data.Maybe (fromMaybe)
41+import Data.Semigroup (Endo(..))
42+#if __GLASGOW_HASKELL__ < 808
43+import Data.Semigroup (Semigroup(..))
44+#endif
45+import GHC.Exts (IsList(..), IsString(..), oneShot)
46+import Text.Read
47+ ( Lexeme(Ident), lexP, parens, prec, readPrec, readListPrec
48+ , readListPrecDefault)
49+import Streamly.Internal.BaseCompat ((#.))
50+import Streamly.Internal.Data.Maybe.Strict (Maybe'(..), toMaybe)
51+import Streamly.Internal.Data.Stream.StreamK.Type
52+ (Stream, mkStream, foldStream)
53+
54+import qualified Streamly.Internal.Data.Stream.Common as P
55+import qualified Streamly.Internal.Data.Stream.StreamD.Generate as D
56+import qualified Streamly.Internal.Data.Stream.StreamD.Type as D
57+import qualified Streamly.Internal.Data.Stream.StreamK.Type as K
58+
59+import Prelude hiding (map, mapM, repeat, filter)
60+
61+#include "Instances.hs"
62+#include "inline.hs"
63+
64+-- $setup
65+-- >>> import qualified Streamly.Prelude as Stream
66+
67+------------------------------------------------------------------------------
68+-- WSerialT
69+------------------------------------------------------------------------------
70+
71+-- | For 'WSerialT' streams:
72+--
73+-- @
74+-- (<>) = 'Streamly.Prelude.wSerial' -- 'Semigroup'
75+-- (>>=) = flip . 'Streamly.Prelude.concatMapWith' 'Streamly.Prelude.wSerial' -- 'Monad'
76+-- @
77+--
78+-- Note that '<>' is associative only if we disregard the ordering of elements
79+-- in the resulting stream.
80+--
81+-- A single 'Monad' bind behaves like a @for@ loop:
82+--
83+-- >>> :{
84+-- Stream.toList $ Stream.fromWSerial $ do
85+-- x <- Stream.fromList [1,2] -- foreach x in stream
86+-- return x
87+-- :}
88+-- [1,2]
89+--
90+-- Nested monad binds behave like interleaved nested @for@ loops:
91+--
92+-- >>> :{
93+-- Stream.toList $ Stream.fromWSerial $ do
94+-- x <- Stream.fromList [1,2] -- foreach x in stream
95+-- y <- Stream.fromList [3,4] -- foreach y in stream
96+-- return (x, y)
97+-- :}
98+-- [(1,3),(2,3),(1,4),(2,4)]
99+--
100+-- It is a result of interleaving all the nested iterations corresponding to
101+-- element @1@ in the first stream with all the nested iterations of element
102+-- @2@:
103+--
104+-- >>> import Streamly.Prelude (wSerial)
105+-- >>> Stream.toList $ Stream.fromList [(1,3),(1,4)] `Stream.wSerial` Stream.fromList [(2,3),(2,4)]
106+-- [(1,3),(2,3),(1,4),(2,4)]
107+--
108+-- The @W@ in the name stands for @wide@ or breadth wise scheduling in
109+-- contrast to the depth wise scheduling behavior of 'SerialT'.
110+--
111+-- /Since: 0.2.0 ("Streamly")/
112+--
113+-- @since 0.8.0
114+newtype WSerialT m a = WSerialT {getWSerialT :: Stream m a}
115+ deriving (MonadTrans)
116+
117+-- | An interleaving serial IO stream of elements of type @a@. See 'WSerialT'
118+-- documentation for more details.
119+--
120+-- /Since: 0.2.0 ("Streamly")/
121+--
122+-- @since 0.8.0
123+type WSerial = WSerialT IO
124+
125+{-# INLINE consMWSerial #-}
126+{-# SPECIALIZE consMWSerial :: IO a -> WSerialT IO a -> WSerialT IO a #-}
127+consMWSerial :: Monad m => m a -> WSerialT m a -> WSerialT m a
128+consMWSerial m (WSerialT ms) = WSerialT $ K.consM m ms
129+
130+------------------------------------------------------------------------------
131+-- Semigroup
132+------------------------------------------------------------------------------
133+
134+infixr 6 `wSerial`
135+
136+-- Additionally we can have m elements yield from the first stream and n
137+-- elements yielding from the second stream. We can also have time slicing
138+-- variants of positional interleaving, e.g. run first stream for m seconds and
139+-- run the second stream for n seconds.
140+--
141+-- Similar combinators can be implemented using WAhead style.
142+
143+{-# INLINE wSerialK #-}
144+wSerialK :: Stream m a -> Stream m a -> Stream m a
145+wSerialK m1 m2 = mkStream $ \st yld sng stp -> do
146+ let stop = foldStream st yld sng stp m2
147+ single a = yld a m2
148+ yieldk a r = yld a (wSerialK m2 r)
149+ foldStream st yieldk single stop m1
150+
151+-- | Interleaves two streams, yielding one element from each stream
152+-- alternately. When one stream stops the rest of the other stream is used in
153+-- the output stream.
154+
155+-- Scheduling Notes:
156+--
157+-- Note that evaluation of @a \`wSerial` b \`wSerial` c@ does not interleave
158+-- @a@, @b@ and @c@ with equal priority. This expression is equivalent to @a
159+-- \`wSerial` (b \`wSerial` c)@, therefore, it fairly interleaves @a@ with the
160+-- result of @b \`wSerial` c@. For example, @Stream.fromList [1,2] \`wSerial`
161+-- Stream.fromList [3,4] \`wSerial` Stream.fromList [5,6]@ would result in
162+-- [1,3,2,5,4,6]. In other words, the leftmost stream gets the same scheduling
163+-- priority as the rest of the streams taken together. The same is true for
164+-- each subexpression on the right.
165+--
166+{-# INLINE wSerial #-}
167+wSerial :: WSerialT m a -> WSerialT m a -> WSerialT m a
168+wSerial (WSerialT m1) (WSerialT m2) = WSerialT $ wSerialK m1 m2
169+
170+-- | Like `wSerial` but stops interleaving as soon as the first stream stops.
171+--
172+-- @since 0.7.0
173+{-# INLINE wSerialFstK #-}
174+wSerialFstK :: Stream m a -> Stream m a -> Stream m a
175+wSerialFstK m1 m2 = mkStream $ \st yld sng stp -> do
176+ let yieldFirst a r = yld a (yieldSecond r m2)
177+ in foldStream st yieldFirst sng stp m1
178+
179+ where
180+
181+ yieldSecond s1 s2 = mkStream $ \st yld sng stp -> do
182+ let stop = foldStream st yld sng stp s1
183+ single a = yld a s1
184+ yieldk a r = yld a (wSerialK s1 r)
185+ in foldStream st yieldk single stop s2
186+
187+{-# INLINE wSerialFst #-}
188+wSerialFst :: WSerialT m a -> WSerialT m a -> WSerialT m a
189+wSerialFst (WSerialT m1) (WSerialT m2) = WSerialT $ wSerialFstK m1 m2
190+
191+-- | Like `wSerial` but stops interleaving as soon as any of the two streams
192+-- stops.
193+--
194+-- @since 0.7.0
195+{-# INLINE wSerialMinK #-}
196+wSerialMinK :: Stream m a -> Stream m a -> Stream m a
197+wSerialMinK m1 m2 = mkStream $ \st yld _ stp -> do
198+ let stop = stp
199+ -- "single a" is defined as "yld a (wSerialMin m2 K.nil)" instead of
200+ -- "sng a" to keep the behaviour consistent with the yield continuation.
201+ single a = yld a (wSerialMinK m2 K.nil)
202+ yieldk a r = yld a (wSerialMinK m2 r)
203+ foldStream st yieldk single stop m1
204+
205+{-# INLINE wSerialMin #-}
206+wSerialMin :: WSerialT m a -> WSerialT m a -> WSerialT m a
207+wSerialMin (WSerialT m1) (WSerialT m2) = WSerialT $ wSerialMinK m1 m2
208+
209+instance Semigroup (WSerialT m a) where
210+ (<>) = wSerial
211+
212+------------------------------------------------------------------------------
213+-- Monoid
214+------------------------------------------------------------------------------
215+
216+instance Monoid (WSerialT m a) where
217+ mempty = WSerialT K.nil
218+ mappend = (<>)
219+
220+{-# INLINE apWSerial #-}
221+apWSerial :: Monad m => WSerialT m (a -> b) -> WSerialT m a -> WSerialT m b
222+apWSerial (WSerialT m1) (WSerialT m2) =
223+ let f x1 = K.concatMapWith wSerialK (pure . x1) m2
224+ in WSerialT $ K.concatMapWith wSerialK f m1
225+
226+instance Monad m => Applicative (WSerialT m) where
227+ {-# INLINE pure #-}
228+ pure = WSerialT . K.fromPure
229+ {-# INLINE (<*>) #-}
230+ (<*>) = apWSerial
231+
232+------------------------------------------------------------------------------
233+-- Monad
234+------------------------------------------------------------------------------
235+
236+instance Monad m => Monad (WSerialT m) where
237+ return = pure
238+ {-# INLINE (>>=) #-}
239+ (>>=) (WSerialT m) f = WSerialT $ K.bindWith wSerialK m (getWSerialT . f)
240+
241+------------------------------------------------------------------------------
242+-- Other instances
243+------------------------------------------------------------------------------
244+
245+MONAD_COMMON_INSTANCES(WSerialT,)
246+LIST_INSTANCES(WSerialT)
247+NFDATA1_INSTANCE(WSerialT)
248+FOLDABLE_INSTANCE(WSerialT)
249+TRAVERSABLE_INSTANCE(WSerialT)
core/streamly-core.cabal+1
@@ -290,6 +290,7 @@ library
290290 , Streamly.Internal.Data.Parser
291291 , Streamly.Internal.Data.Pipe
292292 , Streamly.Internal.Data.Stream.Serial
293+ , Streamly.Internal.Data.Stream.WSerial
293294 , Streamly.Internal.Data.Stream.Zip
294295 , Streamly.Internal.Data.List
295296
src/Streamly/Internal/Data/Stream/IsStream/Expand.hs+4−4
@@ -52,8 +52,8 @@ module Streamly.Internal.Data.Stream.IsStream.Expand
5252 -- streams that come earlier in the composition.
5353 --
5454 , wSerial
55− , Serial.wSerialFst
56− , Serial.wSerialMin
55+ , WSerial.wSerialFst
56+ , WSerial.wSerialMin
5757
5858 -- ** Interleave
5959 -- | 'interleave' is like 'wSerial' but using a direct style
@@ -175,7 +175,7 @@ import Streamly.Internal.Data.Unfold.Type (Unfold)
175175
176176import qualified Streamly.Internal.Data.Stream.IsStream.Type as IsStream
177177import qualified Streamly.Internal.Data.Stream.Parallel as Par
178−import qualified Streamly.Internal.Data.Stream.Serial as Serial
178+import qualified Streamly.Internal.Data.Stream.WSerial as WSerial
179179import qualified Streamly.Internal.Data.Stream.StreamD as D
180180import qualified Streamly.Internal.Data.Stream.StreamK as K (mergeBy, mergeByM)
181181import qualified Streamly.Internal.Data.Stream.StreamK.Type as K
@@ -285,7 +285,7 @@ infixr 6 `wSerial`
285285--
286286{-# INLINE wSerial #-}
287287wSerial :: IsStream t => t m a -> t m a -> t m a
288−wSerial m1 m2 = fromStream $ Serial.wSerialK (toStream m1) (toStream m2)
288+wSerial m1 m2 = fromStream $ WSerial.wSerialK (toStream m1) (toStream m2)
289289
290290-- XXX Same as 'wSerial'. We should perhaps rename wSerial to interleave.
291291-- XXX Document the interleaving behavior of side effects in all the
src/Streamly/Internal/Data/Stream/IsStream/Generate.hs+2−1
@@ -101,7 +101,8 @@ import Streamly.Internal.Data.Stream.IsStream.Common
101101 , yield, yieldM, repeatM)
102102import Streamly.Internal.Data.Stream.IsStream.Type
103103 (IsStream (..), fromSerial, consM, fromStreamD, fromStreamS)
104−import Streamly.Internal.Data.Stream.Serial (SerialT(..), WSerialT)
104+import Streamly.Internal.Data.Stream.Serial (SerialT(..))
105+import Streamly.Internal.Data.Stream.WSerial (WSerialT)
105106import Streamly.Internal.Data.Stream.Zip (ZipSerialM)
106107import Streamly.Internal.Data.Time.Units (AbsTime , RelTime64, addToAbsTime64)
107108
src/Streamly/Internal/Data/Stream/IsStream/Type.hs+5−4
@@ -105,8 +105,8 @@ where
105105
106106import Streamly.Internal.Control.Concurrent (MonadAsync)
107107import Streamly.Internal.Data.Fold.Type (Fold (..))
108−import Streamly.Internal.Data.Stream.Serial
109− (SerialT(..), Serial, WSerialT(..), WSerial)
108+import Streamly.Internal.Data.Stream.Serial (SerialT(..), Serial)
109+import Streamly.Internal.Data.Stream.WSerial (WSerialT(..), WSerial)
110110import Streamly.Internal.Data.Stream.Async
111111 (AsyncT(..), Async, WAsyncT(..), WAsync)
112112import Streamly.Internal.Data.Stream.Ahead (AheadT(..), Ahead)
@@ -120,6 +120,7 @@ import qualified Streamly.Internal.Data.Stream.Ahead as Ahead
120120import qualified Streamly.Internal.Data.Stream.Async as Async
121121import qualified Streamly.Internal.Data.Stream.Parallel as Parallel
122122import qualified Streamly.Internal.Data.Stream.Serial as Serial
123+import qualified Streamly.Internal.Data.Stream.WSerial as WSerial
123124import qualified Streamly.Internal.Data.Stream.StreamD.Type as D
124125import qualified Streamly.Internal.Data.Stream.StreamK.Type as K
125126#ifdef USE_STREAMK_ONLY
@@ -489,12 +490,12 @@ instance IsStream WSerialT where
489490 {-# INLINE consM #-}
490491 {-# SPECIALIZE consM :: IO a -> WSerialT IO a -> WSerialT IO a #-}
491492 consM :: Monad m => m a -> WSerialT m a -> WSerialT m a
492− consM = Serial.consMWSerial
493+ consM = WSerial.consMWSerial
493494
494495 {-# INLINE (|:) #-}
495496 {-# SPECIALIZE (|:) :: IO a -> WSerialT IO a -> WSerialT IO a #-}
496497 (|:) :: Monad m => m a -> WSerialT m a -> WSerialT m a
497− (|:) = Serial.consMWSerial
498+ (|:) = WSerial.consMWSerial
498499
499500-------------------------------------------------------------------------------
500501-- Async
streamly.cabal+1
@@ -193,6 +193,7 @@ extra-source-files:
193193 core/src/Streamly/Internal/Data/Parser.hs
194194 core/src/Streamly/Internal/Data/Pipe.hs
195195 core/src/Streamly/Internal/Data/Stream/Serial.hs
196+ core/src/Streamly/Internal/Data/Stream/WSerial.hs
196197 core/src/Streamly/Internal/Data/Stream/Zip.hs
197198 core/src/Streamly/Internal/Data/List.hs
198199 core/src/Streamly/Internal/Data/Array.hs
test/Streamly/Test/Prelude/WSerial.hs+2−2
@@ -18,7 +18,7 @@ import Test.Hspec.QuickCheck
1818import Test.QuickCheck.Monadic (monadicIO, run)
1919import Test.Hspec as H
2020
21−import qualified Streamly.Internal.Data.Stream.Serial as Serial
21+import qualified Streamly.Internal.Data.Stream.WSerial as WSerial
2222
2323import Streamly.Prelude hiding (repeat)
2424import qualified Streamly.Prelude as S
@@ -67,7 +67,7 @@ wSerialMinLengthProp =
6767
6868 finiteStream len = S.take len $ S.repeat (1 :: Int)
6969 infiniteStream = S.repeat 1
70− combined len = infiniteStream `Serial.wSerialMin` finiteStream len
70+ combined len = infiniteStream `WSerial.wSerialMin` finiteStream len
7171
7272moduleName :: String
7373moduleName = "Prelude.WSerial"