Skip to content

Commit 104129b

Browse files
committed
Clarify AVar examples
1 parent d94b4a1 commit 104129b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ The `Control.Monad.Aff.AVar` module contains asynchronous variables, which
212212
are very similar to Haskell's `MVar`.
213213

214214
`AVar`s represent a value that is either full or empty. Calling `takeVar` on
215-
an empty `AVar` will queue until it is filled by a matching `putVar`.
215+
an empty `AVar` will queue until it is filled by a `putVar`.
216216

217217
```purescript
218218
example = do
@@ -230,22 +230,23 @@ example = do
230230
> Got a value: hello
231231
```
232232

233-
Likewise, calling `putVar` will queue until it is taken:
233+
Likewise, calling `putVar` on a filled `AVar` will queue until it is emptied by
234+
a `takeVar`.
234235

235236
```purescript
236237
example = do
237-
var <- makeEmptyVar
238+
var <- makeVar "hello"
238239
_ <- forkAff do
239240
delay (Milliseconds 100.0)
240241
value <- takeVar var
241242
log $ "Got a value: " <> value
242-
putVar var "hello"
243-
log "Value taken"
243+
putVar var "next"
244+
log "Value put"
244245
```
245246
```
246247
(Waits 100ms)
247-
> Value taken
248248
> Got a value: hello
249+
> Value put
249250
```
250251

251252
These combinators (and a few more) can be used as the building blocks for

0 commit comments

Comments
 (0)