From 6cde979324005602cb9154cdda64a126ba4839bd Mon Sep 17 00:00:00 2001 From: Ang Hao Yang Date: Thu, 3 Oct 2024 05:39:05 +0800 Subject: [PATCH] Refactor Control.Monad.Error.Class.withError. --- Control/Monad/Error/Class.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Control/Monad/Error/Class.hs b/Control/Monad/Error/Class.hs index 93e3af3..956d90c 100644 --- a/Control/Monad/Error/Class.hs +++ b/Control/Monad/Error/Class.hs @@ -218,7 +218,7 @@ tryError action = (Right <$> action) `catchError` (pure . Left) -- -- @since 2.3 withError :: MonadError e m => (e -> e) -> m a -> m a -withError f action = tryError action >>= either (throwError . f) pure +withError f = handleError (throwError . f) -- | As 'handle' is flipped 'Control.Exception.catch', 'handleError' -- is flipped 'catchError'.