feat(utils): throwLeftWith to facilitate ldap code

This commit is contained in:
Steffen Jost 2022-08-26 14:29:46 +02:00
parent 5f65e68b26
commit 8417eb57c9

View File

@ -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