My understanding of one of the distinctions between Monad
and Applicative
is that flatMap
is available on Monad
, but not Applicative
.
If that's true, I'm confused by these Scala Play JSON docs:
So what’s interesting there is that JsResult[A] is a monadic structure and can be used with classic functions of such structures:
flatMap[X](f: A => JsResult[X]): JsResult[X]
etc
But, then the docs go on to say:
Please note that JsResult[A] is not just Monadic but Applicative because it cumulates errors. This cumulative feature makes JsResult[T] makes it not very good to be used with for comprehension because you’ll get only the first error and not all.
Since, as I understand, a for-comprehension
is syntactic sugar for flatMap
, how can JsResult
be both a Applicative
and Monad
?