@@ -40,9 +40,6 @@ module Streamly.Tutorial
40 -- * Flavors of Streams
40 -- * Flavors of Streams
41 -- $flavors
41 -- $flavors
43− -- * Writing Concurrent Programs
46 -- * Imports and Supporting Code
43 -- * Imports and Supporting Code
47 -- $imports
44 -- $imports
@@ -129,6 +126,9 @@ module Streamly.Tutorial
129 -- * Reactive Programming
126 -- * Reactive Programming
130 -- $reactive
127 -- $reactive
129+ -- * Writing Concurrent Programs
132 -- * Performance
132 -- * Performance
133 -- $performance
133 -- $performance
@@ -238,14 +238,19 @@ import Control.Monad.Trans.Class (MonadTrans (lift))
239-- When writing concurrent programs it is advised to not use the concurrent
239-- When writing concurrent programs it is advised to not use the concurrent
240-- style stream combinators blindly at the top level. That might create too
240-- style stream combinators blindly at the top level. That might create too
241−-- much concurrency where it is not even required and therefore degrade
241+-- much concurrency where it is not even required, and can even degrade
242+-- performance in some cases. In some cases it can also lead to surprising
243+-- behavior because of some code that is supposed to be serial becoming
242−-- performance. Please be aware of what all APIs that you have used may become
244+-- concurrent. Please be aware that all concurrency capable APIs that you may
243−-- concurrent when you use a concurrency combinator. For example if you have a
245+-- have used under the scope of a concurrent stream combinator will become
244−-- 'repeatM' somewhere in your program and you use 'parallely' on top, the
246+-- concurrent. For example if you have a 'repeatM' somewhere in your program
247+-- and you use 'parallely' on top, the 'repeatM' becomes fully parallel,
245−-- 'repeatM' becomes fully parallel, resulting into an infinite parallel
248+-- resulting into an infinite parallel execution . Instead, use the
246−-- execution . Instead start with a default serial program and add concurrent
249+-- /Keep It Serial and Stupid/ principle, start with the default serial
247−-- combinators where necessary, and use the 'serially' combinator to suppress
250+-- composition and enable concurrent combinators only when and where necessary.
251+-- When you use a concurrent combinator you can use an explicit 'serially'
248−-- unnecessary concurrency.
252+-- combinator to suppress any unnecessary concurrency under the scope of that
250-- $monadtransformers
255-- $monadtransformers