File tree 1 file changed +31
-0
lines changed 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ ## Module Control.Coroutine.Aff
2
+
3
+ This module defines functions for creating coroutines on top of the ` Aff ` monad.
4
+
5
+ The ` Aff ` monad only supports actions which return a single value, asynchronously, so this
6
+ module provides a principled way to deal with asynchronous _ streams_ of values, and asynchronous consumers
7
+ of streamed data.
8
+
9
+ #### ` produce `
10
+
11
+ ``` purescript
12
+ produce :: forall a r eff. ((Either a r -> Eff (avar :: AVAR | eff) Unit) -> Eff (avar :: AVAR | eff) Unit) -> Producer a (Aff (avar :: AVAR | eff)) r
13
+ ```
14
+
15
+ Create a ` Producer ` using an asynchronous callback.
16
+
17
+ The callback should provide zero or more values of type ` a ` , which will be
18
+ emitted by the ` Producer ` , terminated by an optional value of type ` r ` . No values
19
+ should be provided after a value of type ` r ` has been provided.
20
+
21
+ For example:
22
+
23
+ ``` purescript
24
+ produce \emit -> do
25
+ log "Working..."
26
+ emit (Left "progress")
27
+ log "Done!"
28
+ emit (Right "finished")
29
+ ```
30
+
31
+
You can’t perform that action at this time.
0 commit comments