I am looking at the MonadValidate typeclass from the monad-validate package, and I can’t seem to figure out why the typeclass has the Semigroup constraint on the
e type variable (or the Monad constraint on the m type variable, though I will limit this discussion to the Semigroup constraint).
I understand why we want our errors to be an instance of Semigroup - MonadValidate is “[t]he class of validation monads, intended to be used to validate data structures while collecting errors along the way”. In order to collect errors, we need a way to combine errors from different branches. But I don’t understand why the constraint is on the typeclass declaration. If we removed the Semigroup constraint from the typeclass declaration, wouldn’t it be up to the instance declaration to add it back in?
Is this simply a way of hinting to anyone writing an instance of MonadValidate that they need to be combining errors, since an instance where the errors are not a Semigroup are invalid?