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
88import Control.Monad.Writer.Trans
99import Control.Monad.State.Trans
1010import Data.Either
11+ import Data.Maybe
1112import Data.Monoid
1213
1314class MonadError e m where
1415 throwError :: forall a . e -> m a
1516 catchError :: forall a . m a -> (e -> m a ) -> m a
1617
17- instance monadErrorError :: MonadError e (Either e ) where
18+ instance monadErrorEither :: MonadError e (Either e ) where
1819 throwError = Left
1920 catchError (Left e) h = h e
2021 catchError (Right x) _ = Right x
2122
23+ instance monadErrorMaybe :: MonadError Unit Maybe where
24+ throwError = const Nothing
25+ catchError Nothing f = f unit
26+ catchError (Just a) _ = Just a
27+
2228instance monadErrorErrorT :: (Monad m ) => MonadError e (ErrorT e m ) where
2329 throwError e = ErrorT $ return (Left e)
2430 catchError m h = ErrorT $ do
You can’t perform that action at this time.
0 commit comments