@@ -60,7 +60,6 @@ import Text.Read (Lexeme(Ident), lexP, parens, prec, readPrec, readListPrec,
60 readListPrecDefault)
60 readListPrecDefault)
61import Prelude hiding (map, mapM)
61import Prelude hiding (map, mapM)
63−import Streamly.SVar (adaptState)
64import Streamly.Streams.StreamK (IsStream(..), adapt, Stream, mkStream,
63import Streamly.Streams.StreamK (IsStream(..), adapt, Stream, mkStream,
65 foldStream)
64 foldStream)
66import qualified Streamly.Streams.Prelude as P
65import qualified Streamly.Streams.Prelude as P
@@ -168,17 +167,9 @@ instance IsStream SerialT where
169------------------------------------------------------------------------------
168------------------------------------------------------------------------------
171−-- XXX if foldStreamShared/unShare/adaptState are not efficient in serial case
172−-- we can use a rewrite rule for that for the serial case and then just use a
173−-- bindWith serial here.
175instance Monad m => Monad (SerialT m) where
170instance Monad m => Monad (SerialT m) where
176 return = pure
171 return = pure
177− m >>= f = mkStream $ \st yld sng stp ->
172+ (>>=) = K.bindWith K.serial
178− let run x = foldStream st yld sng stp x
179− single a = run $ f a
180− yieldk a r = run $ f a <> (r >>= f)
181− in foldStream (adaptState st) yieldk single stp m
183------------------------------------------------------------------------------
174------------------------------------------------------------------------------
184-- Other instances
175-- Other instances
@@ -331,17 +322,9 @@ instance Monoid (WSerialT m a) where
332------------------------------------------------------------------------------
323------------------------------------------------------------------------------
334−-- XXX if foldStreamShared/unShare/adaptState are not efficient in serial case
335−-- we can use a rewrite rule for that for the serial case and then just use a
336−-- bindWith interleave here.
338instance Monad m => Monad (WSerialT m) where
325instance Monad m => Monad (WSerialT m) where
339 return = pure
326 return = pure
340− m >>= f = mkStream $ \st yld sng stp ->
327+ (>>=) = K.bindWith wSerial
341− let run x = foldStream st yld sng stp x
342− single a = run $ f a
343− yieldk a r = run $ f a <> (r >>= f)
344− in foldStream (adaptState st) yieldk single stp m
346------------------------------------------------------------------------------
329------------------------------------------------------------------------------
347-- Other instances
330-- Other instances