@@ -5,6 +5,7 @@ module Control.Monad.Aff
55 , PureAff (..)
66 , attempt
77 , forkAff
8+ , later
89 , launchAff
910 , liftEff'
1011 , makeAff
@@ -35,20 +36,16 @@ module Control.Monad.Aff
3536 -- | produces a value of type `a`.
3637 -- |
3738 -- | This is moral equivalent of `ErrorT (ContT Unit (EffA e)) a`.
38- -- |
39- -- | The type implements `MonadEff` so it's easy to lift synchronous `Eff`
40- -- | computations into this type. As a result, there's basically no reason to
41- -- | use `Eff` in a program that has some asynchronous computations.
4239 data Aff e a = Aff ((Error -> Eff e Unit) -> (a -> Eff e Unit) -> EffA e Unit )
4340
4441 type PureAff a = forall e. Aff e a
4542
46- -- | Converts the asynchronous effect into a synchronous one. All values and
47- -- | errors are ignored.
43+ -- | Converts the asynchronous computation into a synchronous one. All values
44+ -- | and errors are ignored.
4845 launchAff :: forall e a. Aff e a -> EffA e Unit
4946 launchAff (Aff fa ) = fa (const (pure unit)) (const (pure unit))
5047
51- -- | Runs the asynchronous effect . You must supply an error callback and a
48+ -- | Runs the asynchronous computation . You must supply an error callback and a
5249 -- | success callback.
5350 runAff :: forall e a. (Error -> Eff e Unit ) -> (a -> Eff e Unit ) -> Aff e a -> EffA e Unit
5451 runAff ex f (Aff v ) = v ex f
@@ -58,6 +55,19 @@ module Control.Monad.Aff
5855 makeAff :: forall e a. ((Error -> Eff e Unit) -> (a -> Eff e Unit) -> EffA e Unit ) -> Aff e a
5956 makeAff = Aff
6057
58+ -- | Runs the asynchronous computation later.
59+ foreign import later " " "
60+ function later(aff) {
61+ return function(error) {
62+ return function(success) {
63+ return function() {
64+ setTimeout(aff(error)(success), 0);
65+ }
66+ }
67+ }
68+ }
69+ " " " :: forall e a. Aff e a -> Aff e a
70+
6171 -- | Forks the specified asynchronous computation so subsequent monadic binds
6272 -- | will not block on the result of the computation.
6373 foreign import forkAff " " "
0 commit comments