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 2626 "purescript-control" : " ^4.0.0" ,
2727 "purescript-distributive" : " ^4.0.0" ,
2828 "purescript-effect" : " ^2.0.0" ,
29+ "purescript-exceptions" : " ^4.0.0" ,
2930 "purescript-either" : " ^4.0.0" ,
3031 "purescript-foldable-traversable" : " ^4.0.0" ,
3132 "purescript-identity" : " ^4.0.0" ,
Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ import Prelude
66
77import Data.Maybe (Maybe (..))
88import Data.Either (Either (..), either )
9+ import Effect (Effect )
10+ import Effect.Exception as Ex
11+
912
1013-- | The `MonadThrow` type class represents those monads which support errors via
1114-- | `throwError`, where `throwError e` halts, yielding the error `e`.
@@ -76,6 +79,13 @@ instance monadThrowMaybe :: MonadThrow Unit Maybe where
7679instance monadErrorMaybe :: MonadError Unit Maybe where
7780 catchError Nothing f = f unit
7881 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+
7989
8090-- | Make sure that a resource is cleaned up in the event of an exception. The
8191-- | release action is called regardless of whether the body action throws or
You can’t perform that action at this time.
0 commit comments