@@ -37,20 +37,20 @@ asynchronously without any callbacks. Error handling is baked in so you only
3737deal with it when you want to.
3838
3939The library contains instances for ` Semigroup ` , ` Monoid ` , ` Apply ` ,
40- ` Applicative ` , ` Bind ` , ` Monad ` , ` Alt ` , ` Plus ` , ` MonadEff ` , ` MonadError ` , and
40+ ` Applicative ` , ` Bind ` , ` Monad ` , ` Alt ` , ` Plus ` , ` MonadEffect ` , ` MonadError ` , and
4141` Parallel ` . These instances allow you to compose asynchronous code as easily
42- as ` Eff ` , as well as interop with existing ` Eff ` code.
42+ as ` Effect ` , as well as interop with existing ` Effect ` code.
4343
4444## Escaping Callback Hell
4545
4646Hopefully, you're using libraries that already use the ` Aff ` type, so you
4747don't even have to think about callbacks!
4848
4949If you're building your own library, then you can make an ` Aff ` from
50- low-level ` Eff ` callbacks with ` makeAff ` .
50+ low-level ` Effect ` callbacks with ` makeAff ` .
5151
5252``` purescript
53- makeAff :: forall eff a. ((Either Error a -> Eff eff Unit) -> Eff eff ( Canceler eff)) -> Aff eff a
53+ makeAff :: forall a. ((Either Error a -> Effect Unit) -> Effect Canceler) -> Aff a
5454```
5555
5656This function expects you to provide a handler, which should call the
@@ -60,7 +60,7 @@ You should also return `Canceler`, which is just a cleanup effect. Since
6060` Aff ` threads may be killed, all asynchronous operations should provide a
6161mechanism for unscheduling it.
6262
63- ` Control.Monad .Aff.Compat` provides functions for easily binding FFI
63+ ` Effect .Aff.Compat` provides functions for easily binding FFI
6464definitions:
6565
6666``` javascript
@@ -84,14 +84,14 @@ exports._ajaxGet = function (request) { // accepts a request
8484```
8585
8686``` purescript
87- foreign import _ajaxGet :: forall eff. Request -> EffFnAff (ajax :: AJAX | eff) Response
87+ foreign import _ajaxGet :: Request -> EffectFnAff Response
8888```
8989
9090We can wrap this into an asynchronous computation like so:
9191
9292``` purescript
93- ajaxGet :: forall eff. Request -> Aff (ajax :: AJAX | eff) Response
94- ajaxGet = fromEffFnAff <<< _ajaxGet
93+ ajaxGet :: Request -> Aff Response
94+ ajaxGet = fromEffectFnAff <<< _ajaxGet
9595```
9696
9797This eliminates callback hell and allows us to write code simply using ` do `
@@ -103,22 +103,18 @@ example = do
103103 log response.body
104104```
105105
106- ## Eff
106+ ## Effect
107107
108- All purely synchronous computations (` Eff ` ) can be lifted to asynchronous
109- computations with ` liftEff ` defined in ` Control.Monad.Eff .Class` .
108+ All purely synchronous computations (` Effect ` ) can be lifted to asynchronous
109+ computations with ` liftEffect ` defined in ` Effect .Class` .
110110
111111``` purescript
112- liftEff $ log "Hello world!"
112+ liftEffect $ log "Hello world!"
113113```
114114
115115This lets you write your whole program in ` Aff ` , and still call out to
116116synchronous code.
117117
118- If your ` Eff ` code throws exceptions (` exception :: EXCEPTION ` ), you can
119- remove the exception label using ` liftEff' ` . Exceptions are part of ` Aff ` s
120- built-in semantics, so they will always be caught and propagated anyway.
121-
122118## Dealing with Failure
123119
124120` Aff ` has error handling baked in, so ordinarily you don't have to worry
@@ -188,7 +184,7 @@ Because Javascript is single-threaded, forking does not actually cause the
188184computation to be run in a separate thread. Forking just allows the subsequent
189185actions to execute without waiting for the forked computation to complete.
190186
191- Forking returns a ` Fiber eff a ` , representing the deferred computation. You can
187+ Forking returns a ` Fiber a ` , representing the deferred computation. You can
192188kill a ` Fiber ` with ` killFiber ` , which will run any cancelers and cleanup, and
193189you can observe a ` Fiber ` 's final value with ` joinFiber ` . If a ` Fiber ` threw
194190an exception, it will be rethrown upon joining.
@@ -203,53 +199,6 @@ example = do
203199 else (log "Not Canceled")
204200```
205201
206-
207- ## AVars
208-
209- The ` Control.Monad.Aff.AVar ` module contains asynchronous variables, which
210- are very similar to Haskell's ` MVar ` .
211-
212- ` AVar ` s represent a value that is either full or empty. Calling ` takeVar ` on
213- an empty ` AVar ` will queue until it is filled by a ` putVar ` .
214-
215- ``` purescript
216- example = do
217- var <- makeEmptyVar
218- _ <- forkAff do
219- value <- takeVar var
220- log $ "Got a value: " <> value
221- _ <- forkAff do
222- delay (Milliseconds 100.0)
223- putVar var "hello"
224- pure unit
225- ```
226- ```
227- (Waits 100ms)
228- > Got a value: hello
229- ```
230-
231- Likewise, calling ` putVar ` on a filled ` AVar ` will queue until it is emptied by
232- a ` takeVar ` .
233-
234- ``` purescript
235- example = do
236- var <- makeVar "hello"
237- _ <- forkAff do
238- delay (Milliseconds 100.0)
239- value <- takeVar var
240- log $ "Got a value: " <> value
241- putVar var "next"
242- log "Value put"
243- ```
244- ```
245- (Waits 100ms)
246- > Got a value: hello
247- > Value put
248- ```
249-
250- These combinators (and a few more) can be used as the building blocks for
251- complex asynchronous coordination.
252-
253202## Parallel Execution
254203
255204The ` Parallel ` instance for ` Aff ` makes writing parallel computations a breeze.
0 commit comments