@@ -60,7 +60,6 @@ import Text.Read (Lexeme(Ident), lexP, parens, prec, readPrec, readListPrec,
6060 readListPrecDefault)
6161import Prelude hiding (map, mapM)
6262
63−import Streamly.SVar (adaptState)
6463import Streamly.Streams.StreamK (IsStream(..), adapt, Stream, mkStream,
6564 foldStream)
6665import qualified Streamly.Streams.Prelude as P
@@ -168,17 +167,9 @@ instance IsStream SerialT where
168167-- Monad
169168------------------------------------------------------------------------------
170169
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.
174−--
175170instance Monad m => Monad (SerialT m) where
176171 return = pure
177− m >>= f = mkStream $ \st yld sng stp ->
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
172+ (>>=) = K.bindWith K.serial
182173
183174------------------------------------------------------------------------------
184175-- Other instances
@@ -331,17 +322,9 @@ instance Monoid (WSerialT m a) where
331322-- Monad
332323------------------------------------------------------------------------------
333324
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.
337−--
338325instance Monad m => Monad (WSerialT m) where
339326 return = pure
340− m >>= f = mkStream $ \st yld sng stp ->
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
327+ (>>=) = K.bindWith wSerial
345328
346329------------------------------------------------------------------------------
347330-- Other instances