@@ -26,7 +26,7 @@ module Control.Monad.Aff
2626 import Control.Monad.Cont.Class (MonadCont )
2727 import Control.Monad.Eff (Eff ())
2828 import Control.Monad.Eff.Class (MonadEff , liftEff )
29- import Control.Monad.Eff.Exception (Error (), EXCEPTION (), catchException , error )
29+ import Control.Monad.Eff.Exception (Error (), EXCEPTION (), catchException , throwException , error )
3030 import Control.Monad.Eff.Unsafe (unsafeInterleaveEff )
3131 import Control.Monad.Error.Class (MonadError , throwError )
3232 import Control.Monad.Rec.Class (MonadRec , tailRecM )
@@ -65,9 +65,12 @@ module Control.Monad.Aff
6565 cancelWith aff c = runFn3 _cancelWith nonCanceler aff c
6666
6767 -- | Converts the asynchronous computation into a synchronous one. All values
68- -- | and errors are ignored.
69- launchAff :: forall e a. Aff e a -> Eff e Unit
70- launchAff = runAff (const (pure unit)) (const (pure unit))
68+ -- | are ignored, and if the computation produces an error, it is thrown.
69+ launchAff :: forall e a. Aff e a -> Eff (err :: EXCEPTION | e ) Unit
70+ launchAff = runAff throwException (const (pure unit)) <<< liftEx
71+ where
72+ liftEx :: forall e a. Aff e a -> Aff (err :: EXCEPTION | e ) a
73+ liftEx = _unsafeInterleaveAff
7174
7275 -- | Runs the asynchronous computation. You must supply an error callback and a
7376 -- | success callback.
0 commit comments