on master help sign in
Update comments about bind impl of SerialT
commit3cd4b10507146ed6040e8a8081b01352e78ea436 authorHarendra Kumar <harendra@composewell.com> dateWed 17 Mar 2021, 02:49 (6 years ago) parent3b1a26c
1 file changed+10−4
src/Streamly/Internal/Data/Stream/Serial.hs+10−4
src/Streamly/Internal/Data/Stream/Serial.hs+10−4
@@ -186,16 +186,22 @@ instance IsStream SerialT where
186186instance Monad m => Monad (SerialT m) where
187187 return = pure
188188
189+ -- Benchmarks better with StreamD bind and pure:
190+ -- toList, filterAllout, *>, *<, >> (~2x)
191+ --
192+ -- pure = SerialT . D.fromStreamD . D.yield
193+ -- m >>= f = D.fromStreamD $ D.concatMap (D.toStreamD . f) (D.toStreamD m)
194+
195+ -- Benchmarks better with CPS bind and pure:
196+ -- Prime sieve (25x)
197+ -- n binds, breakAfterSome, filterAllIn, state transformer (~2x)
198+ --
189199 {-# INLINE (>>=) #-}
190200 (>>=) = K.bindWith K.serial
191201
192202 {-# INLINE (>>) #-}
193203 (>>) = (*>)
194204
195− -- StreamD based implementation
196− -- return = SerialT . D.fromStreamD . D.yield
197− -- m >>= f = D.fromStreamD $ D.concatMap (\a -> D.toStreamD (f a)) (D.toStreamD m)
198−
199205------------------------------------------------------------------------------
200206-- Other instances
201207------------------------------------------------------------------------------