Skip to content

Commit e4682e5

Browse files
committed
update docs
1 parent 2c27dee commit e4682e5

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ This looks like ordinary, synchronous, imperative code, but actually operates as
3737

3838
`Aff` represents a computation with a synchronous component (for example, initiating an AJAX request), as well as an asynchronous component (retrieving an error or success response).
3939

40-
For maximum type safety, `Aff` separates the effects of the synchronous part from the asynchronous part. That is, an `Aff` computation may have one set of effects for its synchronous component, and another set for its asynchronous part.
40+
For maximum type safety, `Aff` separates the effects of the synchronous part from the asynchronous part. That is, an `Aff` computation may have one set of effects for its synchronous part, and another set for its asynchronous part.
4141

42-
Asynchronous effects are represented with an `async :: Async e1` effect label, where `e1` is the row of effects for actions to occur at some point in the future.
42+
Asynchronous effects are represented with an `async :: Async e1` effect label, where `e1` is the row of effects for actions that will occur at some indefinite point in the future.
4343

44-
The library contains instances for `Semigroup`, `Monoid`, `Apply`, `Applicative`, `Bind`, `Monad`, `MonadEff`. and `MonadError`. These instances allow you to compose `Aff`-ectful code as easily as `Eff`, as well as interop with existing `Eff` code.
44+
The library contains instances for `Semigroup`, `Monoid`, `Apply`, `Applicative`, `Bind`, `Monad`, `MonadEff`, and `MonadError`. These instances allow you to compose `Aff`-ectful code as easily as `Eff`, as well as interop with existing `Eff` code.
4545

4646
## Escaping Callback Hell
4747

@@ -102,7 +102,7 @@ to bring the exception to the value level as an `Either Error a`:
102102

103103
```purescript
104104
do e <- liftEff' myExcFunc
105-
liftEff $ either (trace "caught exception") (trace "no exception") e
105+
liftEff $ either (const $ trace "Oh noes!") (const $ trace "Yays!") e
106106
```
107107

108108
## Exceptions
@@ -117,6 +117,11 @@ attempt :: forall e1 e2 a. Aff e1 e2 a -> Aff e1 e2 (Either Error a)
117117

118118
This returns an `Either Error a` you can use to recover gracefully from failure.
119119

120+
```purescript
121+
do e <- attempt $ Ajax.get "http://foo.com"
122+
liftEff $ either (const $ trace "Oh noes!") (const $ trace "Yays!") e
123+
```
124+
120125
`Aff` has a `MonadError` instance, which comes with two functions: `catchError`, and `throwError`.
121126

122127
These are defined in [purescript-transformers](http://github.com/purescript/purescript-transformers).

0 commit comments

Comments
 (0)