Skip to content

Commit 81a0963

Browse files
committed
Merge branch 'master' of github.com:slamdata/purescript-aff
2 parents 1d2dfde + a8efcf2 commit 81a0963

File tree

2 files changed

+40
-22
lines changed

2 files changed

+40
-22
lines changed

MODULES.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
data Aff :: # ! -> * -> *
99
```
1010

11-
A computation with effects `e`. The computation either errors or
11+
A computation with effects `e`. The computation either errors or
1212
produces a value of type `a`.
1313

1414
This is moral equivalent of `ErrorT (ContT Unit (Eff e)) a`.
@@ -34,7 +34,7 @@ type Canceler e = Error -> Aff e Boolean
3434
launchAff :: forall e a. Aff e a -> Eff e Unit
3535
```
3636

37-
Converts the asynchronous computation into a synchronous one. All values
37+
Converts the asynchronous computation into a synchronous one. All values
3838
and errors are ignored.
3939

4040
#### `runAff`
@@ -43,7 +43,7 @@ and errors are ignored.
4343
runAff :: forall e a. (Error -> Eff e Unit) -> (a -> Eff e Unit) -> Aff e a -> Eff e Unit
4444
```
4545

46-
Runs the asynchronous computation. You must supply an error callback and a
46+
Runs the asynchronous computation. You must supply an error callback and a
4747
success callback.
4848

4949
#### `makeAff`
@@ -52,10 +52,20 @@ success callback.
5252
makeAff :: forall e a. ((Error -> Eff e Unit) -> (a -> Eff e Unit) -> Eff e Unit) -> Aff e a
5353
```
5454

55-
Creates an asynchronous effect from a function that accepts error and
55+
Creates an asynchronous effect from a function that accepts error and
5656
success callbacks. This function can be used for asynchronous computations
5757
that cannot be canceled.
5858

59+
#### `makeAff'`
60+
61+
``` purescript
62+
makeAff' :: forall e a. ((Error -> Eff e Unit) -> (a -> Eff e Unit) -> Eff e (Canceler e)) -> Aff e a
63+
```
64+
65+
Creates an asynchronous effect from a function that accepts error and
66+
success callbacks, and returns a canceler for the computation. This
67+
function can be used for asynchronous computations that can be canceled.
68+
5969
#### `later`
6070

6171
``` purescript
@@ -78,7 +88,7 @@ Runs the asynchronous computation later (off the current execution context).
7888
forkAff :: forall e a. Aff e a -> Aff e (Canceler e)
7989
```
8090

81-
Forks the specified asynchronous computation so subsequent monadic binds
91+
Forks the specified asynchronous computation so subsequent monadic binds
8292
will not block on the result of the computation.
8393

8494
#### `attempt`
@@ -175,7 +185,7 @@ instance monadEffAff :: MonadEff e (Aff e)
175185
instance monadErrorAff :: MonadError Error (Aff e)
176186
```
177187

178-
Allows users to catch and throw errors on the error channel of the
188+
Allows users to catch and throw errors on the error channel of the
179189
asynchronous computation. See documentation in `purescript-transformers`.
180190

181191
#### `altAff`
@@ -209,6 +219,9 @@ instance monadPlusAff :: MonadPlus (Aff e)
209219

210220
## Module Control.Monad.Aff.AVar
211221

222+
223+
A low-level primitive for building asynchronous code.
224+
212225
#### `AVAR`
213226

214227
``` purescript
@@ -300,6 +313,10 @@ instance monadAffAff :: MonadAff e (Aff e)
300313

301314
## Module Control.Monad.Aff.Par
302315

316+
317+
A newtype over `Aff` that provides `Applicative` instances that run in
318+
parallel.
319+
303320
#### `Par`
304321

305322
``` purescript

src/Control/Monad/Aff.purs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Control.Monad.Aff
1+
module Control.Monad.Aff
22
( Aff()
33
, Canceler(..)
44
, PureAff(..)
@@ -12,10 +12,11 @@ module Control.Monad.Aff
1212
, launchAff
1313
, liftEff'
1414
, makeAff
15+
, makeAff'
1516
, nonCanceler
1617
, runAff
1718
)
18-
where
19+
where
1920

2021
import Data.Either(Either(..), either)
2122
import Data.Function(Fn2(), Fn3(), runFn2, runFn3)
@@ -31,7 +32,7 @@ module Control.Monad.Aff
3132
import Control.Monad.Eff.Class
3233
import Control.Monad.Error.Class(MonadError, throwError)
3334

34-
-- | A computation with effects `e`. The computation either errors or
35+
-- | A computation with effects `e`. The computation either errors or
3536
-- | produces a value of type `a`.
3637
-- |
3738
-- | This is moral equivalent of `ErrorT (ContT Unit (Eff e)) a`.
@@ -54,24 +55,24 @@ module Control.Monad.Aff
5455
cancelWith :: forall e a. Aff e a -> Canceler e -> Aff e a
5556
cancelWith aff c = runFn3 _cancelWith nonCanceler aff c
5657

57-
-- | Converts the asynchronous computation into a synchronous one. All values
58+
-- | Converts the asynchronous computation into a synchronous one. All values
5859
-- | and errors are ignored.
5960
launchAff :: forall e a. Aff e a -> Eff e Unit
6061
launchAff = runAff (const (pure unit)) (const (pure unit))
6162

62-
-- | Runs the asynchronous computation. You must supply an error callback and a
63+
-- | Runs the asynchronous computation. You must supply an error callback and a
6364
-- | success callback.
6465
runAff :: forall e a. (Error -> Eff e Unit) -> (a -> Eff e Unit) -> Aff e a -> Eff e Unit
6566
runAff ex f aff = runFn3 _runAff ex f aff
6667

67-
-- | Creates an asynchronous effect from a function that accepts error and
68+
-- | Creates an asynchronous effect from a function that accepts error and
6869
-- | success callbacks. This function can be used for asynchronous computations
6970
-- | that cannot be canceled.
7071
makeAff :: forall e a. ((Error -> Eff e Unit) -> (a -> Eff e Unit) -> Eff e Unit) -> Aff e a
7172
makeAff h = makeAff' (\e a -> const nonCanceler <$> h e a)
7273

73-
-- | Creates an asynchronous effect from a function that accepts error and
74-
-- | success callbacks, and returns a canceler for the computation. This
74+
-- | Creates an asynchronous effect from a function that accepts error and
75+
-- | success callbacks, and returns a canceler for the computation. This
7576
-- | function can be used for asynchronous computations that can be canceled.
7677
makeAff' :: forall e a. ((Error -> Eff e Unit) -> (a -> Eff e Unit) -> Eff e (Canceler e)) -> Aff e a
7778
makeAff' h = _makeAff h
@@ -84,7 +85,7 @@ module Control.Monad.Aff
8485
later' :: forall e a. Number -> Aff e a -> Aff e a
8586
later' n aff = runFn3 _setTimeout nonCanceler n aff
8687

87-
-- | Forks the specified asynchronous computation so subsequent monadic binds
88+
-- | Forks the specified asynchronous computation so subsequent monadic binds
8889
-- | will not block on the result of the computation.
8990
forkAff :: forall e a. Aff e a -> Aff e (Canceler e)
9091
forkAff aff = runFn2 _forkAff nonCanceler aff
@@ -128,7 +129,7 @@ module Control.Monad.Aff
128129
instance monadEffAff :: MonadEff e (Aff e) where
129130
liftEff eff = runFn2 _liftEff nonCanceler eff
130131

131-
-- | Allows users to catch and throw errors on the error channel of the
132+
-- | Allows users to catch and throw errors on the error channel of the
132133
-- | asynchronous computation. See documentation in `purescript-transformers`.
133134
instance monadErrorAff :: MonadError Error (Aff e) where
134135
throwError e = runFn2 _throwError nonCanceler e
@@ -278,7 +279,7 @@ module Control.Monad.Aff
278279
} catch (e) {
279280
error(e);
280281
}
281-
282+
282283
return canceler;
283284
}
284285
}""" :: forall e a. Fn2 (Canceler e) a (Aff e a)
@@ -287,7 +288,7 @@ module Control.Monad.Aff
287288
function _throwError(canceler, e) {
288289
return function(success, error) {
289290
error(e);
290-
291+
291292
return canceler;
292293
}
293294
}""" :: forall e a. Fn2 (Canceler e) Error (Aff e a)
@@ -309,15 +310,15 @@ module Control.Monad.Aff
309310
function _bind(aff, f) {
310311
return function(success, error) {
311312
var canceler;
312-
313+
313314
canceler = aff(function(v) {
314-
try {
315+
try {
315316
canceler = f(v)(success, error);
316317
} catch (e) {
317318
error(e);
318319
}
319320
}, error);
320-
321+
321322
return function(e) {
322323
return function(success, error) {
323324
return canceler(e)(success, error);
@@ -368,7 +369,7 @@ module Control.Monad.Aff
368369
} catch (e) {
369370
error(e);
370371
}
371-
372+
372373
return canceler;
373374
};
374375
}""" :: forall e a. Fn2 (Canceler e) (Eff e a) (Aff e a)

0 commit comments

Comments
 (0)