RlpcError

This commit is contained in:
crumbtoo
2023-12-28 15:55:24 -07:00
parent c2960e4acc
commit 526bf0734e
7 changed files with 58 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ module Control.Monad.Errorful
, runErrorfulT
, Errorful
, runErrorful
, mapErrors
, MonadErrorful(..)
)
where
@@ -63,3 +64,10 @@ instance (Monad m) => Monad (ErrorfulT e m) where
Right (a,es) -> runErrorfulT (k a)
Left e -> pure (Left e)
mapErrors :: (Monad m) => (e -> e') -> ErrorfulT e m a -> ErrorfulT e' m a
mapErrors f m = ErrorfulT $ do
x <- runErrorfulT m
case x of
Left e -> pure . Left $ f e
Right (a,es) -> pure . Right $ (a, f <$> es)