remember the coversation we had the other day
# arrow
p
remember the coversation we had the other day
s
Why can't we add this to Validated.
Copy code
fun <E, A, B> Validated<E, A>.flatMap(f: (A) -> Validated<E, B>): Validated<E, B> {
  return when (this) {
    is Invalid -> this
    is Valid -> f(this.a)
  }
}
p
You can do an experiment. Add a Monad instance ForValidated, then use testLaws(MonadLaws.laws(Validated.monad(), EQ)) to test whether it passes all the necessary tests
IIRC it should fail some of them
s
Ok, but assuming it fails some of them, cannot this be added under a different name. It's super useful.