From the documentation of the validation
package:
The
AccValidation
data type is isomorphic toEither
, but has an instance ofApplicative
that accumulates on the error side. That is to say, if two (or more) errors are encountered, they are appended using aSemigroup
operation.As a consequence of this
Applicative
instance, there is no correspondingBind
orMonad
instance.AccValidation
is an example of, "An applicative functor that is not a monad."
It isn't evident to me why this is a consequence. I can imagine a Monad
instance for AccValidation
that behaves like Either
- What would make this unlawful?
Either
accumulates on the non-error side. – HigherupEither
doesn't "accumulate" at all in the same sense thatAccValidation
accumulates, right? – Gosserap = (<*>)
is part of the contract of theMonad
class, as stated by the documentation you linked to, it isn't, strictly speaking, a monad law -- it's just that it would be horribly confusing if it didn't hold. Here is a highly relevant question, with answers and comments that approach the issue from many different perspectives. – Inessive