@@ -25,10 +25,10 @@ import Prelude
25
25
import Control.Alt (class Alt )
26
26
import Control.Alternative (class Alternative )
27
27
import Control.Monad.Aff.Internal (AVBox , AVar , _killVar , _putVar , _takeVar , _makeVar )
28
- import Control.Monad.Eff (Eff )
28
+ import Control.Monad.Eff (Eff , kind Effect )
29
29
import Control.Monad.Eff.Class (class MonadEff )
30
30
import Control.Monad.Eff.Exception (Error , EXCEPTION , throwException , error )
31
- import Control.Monad.Error.Class (class MonadError , throwError )
31
+ import Control.Monad.Error.Class (class MonadThrow , class MonadError , throwError )
32
32
import Control.Monad.Rec.Class (class MonadRec , Step (..))
33
33
import Control.MonadPlus (class MonadZero , class MonadPlus )
34
34
import Control.Parallel (class Parallel )
@@ -46,7 +46,7 @@ import Unsafe.Coerce (unsafeCoerce)
46
46
-- | errors or produces a value of type `a`.
47
47
-- |
48
48
-- | This is moral equivalent of `ErrorT (ContT Unit (Eff e)) a`.
49
- foreign import data Aff :: # ! -> * -> *
49
+ foreign import data Aff :: # Effect -> Type -> Type
50
50
51
51
-- | A pure asynchronous computation, having no effects other than
52
52
-- | asynchronous computation.
@@ -79,12 +79,12 @@ cancelWith aff c = runFn3 _cancelWith nonCanceler aff c
79
79
-- | If you do need to handle exceptions, you can use `runAff` instead, or
80
80
-- | you can handle the exception within the Aff computation, using
81
81
-- | `catchError` (or any of the other mechanisms).
82
- launchAff :: forall e a . Aff e a -> Eff (err :: EXCEPTION | e ) (Canceler e )
82
+ launchAff :: forall e a . Aff e a -> Eff (exception :: EXCEPTION | e ) (Canceler e )
83
83
launchAff = lowerEx <<< runAff throwException (const (pure unit)) <<< liftEx
84
84
where
85
- liftEx :: Aff e a -> Aff (err :: EXCEPTION | e ) a
85
+ liftEx :: Aff e a -> Aff (exception :: EXCEPTION | e ) a
86
86
liftEx = _unsafeInterleaveAff
87
- lowerEx :: Eff (err :: EXCEPTION | e ) (Canceler (err :: EXCEPTION | e )) -> Eff (err :: EXCEPTION | e ) (Canceler e )
87
+ lowerEx :: Eff (exception :: EXCEPTION | e ) (Canceler (exception :: EXCEPTION | e )) -> Eff (exception :: EXCEPTION | e ) (Canceler e )
88
88
lowerEx = map (Canceler <<< map _unsafeInterleaveAff <<< cancel )
89
89
90
90
-- | Runs the asynchronous computation. You must supply an error callback and a
@@ -120,7 +120,7 @@ later' n aff = runFn3 _setTimeout nonCanceler n aff
120
120
finally :: forall e a b . Aff e a -> Aff e b -> Aff e a
121
121
finally aff1 aff2 = do
122
122
x <- attempt aff1
123
- aff2
123
+ _ <- aff2
124
124
either throwError pure x
125
125
126
126
-- | Forks the specified asynchronous computation so subsequent computations
@@ -148,7 +148,7 @@ apathize :: forall e a. Aff e a -> Aff e Unit
148
148
apathize a = const unit <$> attempt a
149
149
150
150
-- | Lifts a synchronous computation and makes explicit any failure from exceptions.
151
- liftEff' :: forall e a . Eff (err :: EXCEPTION | e ) a -> Aff e (Either Error a )
151
+ liftEff' :: forall e a . Eff (exception :: EXCEPTION | e ) a -> Aff e (Either Error a )
152
152
liftEff' eff = attempt (_unsafeInterleaveAff (runFn2 _liftEff nonCanceler eff))
153
153
154
154
-- | A constant canceller that always returns false.
@@ -182,11 +182,14 @@ instance monadAff :: Monad (Aff e)
182
182
instance monadEffAff :: MonadEff e (Aff e ) where
183
183
liftEff eff = runFn2 _liftEff nonCanceler eff
184
184
185
- -- | Allows users to catch and throw errors on the error channel of the
185
+ -- | Allows users to throw errors on the error channel of the
186
186
-- | asynchronous computation. See documentation in `purescript-transformers`.
187
- instance monadErrorAff :: MonadError Error (Aff e ) where
187
+ instance monadThrowAff :: MonadThrow Error (Aff e ) where
188
188
throwError e = runFn2 _throwError nonCanceler e
189
189
190
+ -- | Allows users to catch errors on the error channel of the
191
+ -- | asynchronous computation. See documentation in `purescript-transformers`.
192
+ instance monadErrorAff :: MonadError Error (Aff e ) where
190
193
catchError aff ex = attempt aff >>= either ex pure
191
194
192
195
instance altAff :: Alt (Aff e ) where
0 commit comments