File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change 26
26
"purescript-control" : " ^4.0.0" ,
27
27
"purescript-distributive" : " ^4.0.0" ,
28
28
"purescript-effect" : " ^2.0.0" ,
29
+ "purescript-exceptions" : " ^4.0.0" ,
29
30
"purescript-either" : " ^4.0.0" ,
30
31
"purescript-foldable-traversable" : " ^4.0.0" ,
31
32
"purescript-identity" : " ^4.0.0" ,
Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ import Prelude
6
6
7
7
import Data.Maybe (Maybe (..))
8
8
import Data.Either (Either (..), either )
9
+ import Effect (Effect )
10
+ import Effect.Exception as Ex
11
+
9
12
10
13
-- | The `MonadThrow` type class represents those monads which support errors via
11
14
-- | `throwError`, where `throwError e` halts, yielding the error `e`.
@@ -76,6 +79,13 @@ instance monadThrowMaybe :: MonadThrow Unit Maybe where
76
79
instance monadErrorMaybe :: MonadError Unit Maybe where
77
80
catchError Nothing f = f unit
78
81
catchError (Just a) _ = Just a
82
+
83
+ instance monadThrowEffect :: MonadThrow Ex.Error Effect where
84
+ throwError = Ex .throwException
85
+
86
+ instance monadErrorEffect :: MonadError Ex.Error Effect where
87
+ catchError = flip Ex .catchException
88
+
79
89
80
90
-- | Make sure that a resource is cleaned up in the event of an exception. The
81
91
-- | release action is called regardless of whether the body action throws or
You can’t perform that action at this time.
0 commit comments