From 8417eb57c9b8324cee81cbd16ff72f6039757a8e Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Fri, 26 Aug 2022 14:29:46 +0200 Subject: [PATCH] feat(utils): throwLeftWith to facilitate ldap code --- src/Utils.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Utils.hs b/src/Utils.hs index 9567d12c9..259cfea21 100644 --- a/src/Utils.hs +++ b/src/Utils.hs @@ -883,6 +883,11 @@ whenIsRight (Left _) _ = pure () throwLeft :: (MonadThrow m, Exception exc) => Either exc a -> m a throwLeft = either throwM return +throwLeftWith :: (MonadThrow m, Exception e) => e -> Either b a -> m a +-- throwLeftWith e = either (const $ throwM e) return +throwLeftWith _ (Right x) = return x +throwLeftWith e (Left _) = throwM e + {- Just a reminder for Steffen: mapLeft :: (a -> c) -> Either a b -> Either c b mapLeft = over _Left