This pattern is totally embedded into the non-monadic applicative Either sometimes called Validation
data Validation e a
= Collect e
| Value a
deriving Functor
instance Monoid e => Applicative (Validation e) where
pure a = Value a
Collect le <*> Collect re = Collect (le <> re)
Collect e <*> _ = Collect e
_ <*> Collect e = Collect e
Value f <*> Value a = Value (f a)
There is no monad instance for this which lets us scoot forward through a computation and and all of the errors at once.