module Morley.Util.Exception
(
throwLeft
) where
throwLeft :: (MonadThrow m, Exception e) => m (Either e a) -> m a
throwLeft :: forall (m :: * -> *) e a.
(MonadThrow m, Exception e) =>
m (Either e a) -> m a
throwLeft =
(m (Either e a) -> (Either e a -> m a) -> m a
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Left e
e -> e -> m a
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM e
e
Right a
x -> a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
x)