File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -8,17 +8,23 @@ import Control.Monad.Reader.Trans
8
8
import Control.Monad.Writer.Trans
9
9
import Control.Monad.State.Trans
10
10
import Data.Either
11
+ import Data.Maybe
11
12
import Data.Monoid
12
13
13
14
class MonadError e m where
14
15
throwError :: forall a . e -> m a
15
16
catchError :: forall a . m a -> (e -> m a ) -> m a
16
17
17
- instance monadErrorError :: MonadError e (Either e ) where
18
+ instance monadErrorEither :: MonadError e (Either e ) where
18
19
throwError = Left
19
20
catchError (Left e) h = h e
20
21
catchError (Right x) _ = Right x
21
22
23
+ instance monadErrorMaybe :: MonadError Unit Maybe where
24
+ throwError = const Nothing
25
+ catchError Nothing f = f unit
26
+ catchError (Just a) _ = Just a
27
+
22
28
instance monadErrorErrorT :: (Monad m ) => MonadError e (ErrorT e m ) where
23
29
throwError e = ErrorT $ return (Left e)
24
30
catchError m h = ErrorT $ do
You can’t perform that action at this time.
0 commit comments