Consider the following function:
validateList :: (a -> Either e a) -> [a] -> Either e [a]
validateList validate [] = Right []
validateList validate (x:xs) =
case validate x of
Left err -> Left err
Right y -> case validateList validate xs of
Left err -> Left err
Right ys -> Right $ y:ys
Is there a way to write this in a more concise way? Maybe using the >>= operator?
A bit to think about because there are actually two monads here: [] and Either, although List here is not acting as a monad but just more so as a Traversable