Commit 0db4cf3 1 parent 4908ccb commit 0db4cf3 Copy full SHA for 0db4cf3
File tree 1 file changed +9
-0
lines changed
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ module Control.Monad.Oops
32
32
runOops ,
33
33
suspendM ,
34
34
35
+ catchAsLeftM ,
35
36
catchAndExitFailureM ,
36
37
37
38
throwLeftM ,
@@ -160,6 +161,14 @@ suspendM :: forall x m a n b. ()
160
161
-> ExceptT x n b
161
162
suspendM f = ExceptT . f . runExceptT
162
163
164
+ -- | Catch the specified exception and return the caught value as 'Left'. If no
165
+ -- value was caught, then return the returned value in 'Right'.
166
+ catchAsLeftM :: forall x e m a . ()
167
+ => Monad m
168
+ => ExceptT (Variant (x : e )) m a
169
+ -> ExceptT (Variant e ) m (Either x a )
170
+ catchAsLeftM = catchM @ x (pure . Left ) . fmap Right
171
+
163
172
-- | Catch the specified exception. If that exception is caught, exit the program.
164
173
catchAndExitFailureM :: forall x e m a . ()
165
174
=> MonadIO m
You can’t perform that action at this time.
0 commit comments