File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ import Prelude
66
77import Data.Maybe (Maybe (..))
88import Data.Either (Either (..), either )
9+ import Effect (Effect )
10+ import Effect as Effect
11+ import Effect.Exception (Error )
12+
913
1014-- | The `MonadThrow` type class represents those monads which support errors via
1115-- | `throwError`, where `throwError e` halts, yielding the error `e`.
@@ -76,6 +80,13 @@ instance monadThrowMaybe :: MonadThrow Unit Maybe where
7680instance monadErrorMaybe :: MonadError Unit Maybe where
7781 catchError Nothing f = f unit
7882 catchError (Just a) _ = Just a
83+
84+ instance monadThrowEffect :: MonadThrow Error Effect where
85+ throwError = Effect .throwException
86+
87+ instance monadErrorEffect :: MonadError Error Effect where
88+ catchError = flip Effect .catchException
89+
7990
8091-- | Make sure that a resource is cleaned up in the event of an exception. The
8192-- | release action is called regardless of whether the body action throws or
You can’t perform that action at this time.
0 commit comments