Is there a way to write this function in a more "monadic" way, instead of resorting to pattern matching on Either?
{-# LANGUAGE LambdaCase #-}
calculate :: (Monad m) => (a -> m (Either e b)) -> Either e a -> m (Either e b)
calculate f = \case
Left err -> return $ Left err
Right vals -> f vals
Specifically, for my use case, m is IO; f is a function that takes in input and produces some IO effect or fails, and the input is something that could have failed already.
Maybe using ExceptT?