Skip to content

Commit 49c1783

Browse files
committed
Docs
1 parent b3d3117 commit 49c1783

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

docs/Control/Coroutine/Aff.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+

0 commit comments

Comments
 (0)