on master help sign in
Add concurrent, generation, transformation and application
commit01f0681946f1ad94a0158d7ef3973448c560a4b5 authorHarendra Kumar <harendra.kumar@gmail.com> dateMon 28 May 2018, 12:34 (8 years ago) parent082a4fc
1 file changed+23
README.md+23
README.md+23
@@ -89,6 +89,29 @@ main = runStream $
8989 & S.mapM print
9090```
9191
92+## Concurrent Stream Generation
93+
94+We can use standard monadic stream generation APIs like `repeatM`,
95+`replicateM`, `unfoldrM`, `iterateM` etc. to generate streams in a concurrent
96+manner by using an appropriate stream style combinator.
97+
98+## Concurrent Streaming Pipelines
99+
100+Use `|&` or `|$` to apply stream processing functions concurrently. In the
101+following example "hello" is printed every second, if you use `&` instead of
102+`|&` you will see that the delay doubles to 2 seconds instead because of serial
103+application.
104+
105+```
106+main = runStream $
107+ S.repeatM (threadDelay 1000000 >> return "hello")
108+ |& S.mapM (\x -> threadDelay 1000000 >> putStrLn x)
109+```
110+
111+## Concurrent transformation
112+
113+We can use `mapM` `sequence` concurrently on a stream.
114+
92115## Serial and Concurrent Merging
93116
94117Semigroup and Monoid instances can be used to fold streams serially or