And last question on validation: are there plans t...
# arrow
y
And last question on validation: are there plans to introduce comprehensions for the
Validated
datatype? Or is it not possible? I think it would make composing validation functions easier.
s
Sadly it is not possible 😞 We're considering merging
Either
and
Validated
because they cover the same ADT, but with different strategies. They can be exposed from the same data type, if you name the APIs properly. See following: https://github.com/arrow-kt/arrow/issues/2787 https://github.com/arrow-kt/arrow/pull/2778
Reason why is is not possible.
Copy code
validated<E, Int> {
  val x: Int = validatedA.bind()
  val y: Int = validatedB.bind()
  x + y 
}
If
validatedA
is
E
, then we can never advance this computation unless you have some value for
x
. So
validatedB.bind()
can never be executed, nor can its errors be accumulated.
y
Yeah ok, makes that it doesn't work. My Haskell is somewhat primitive and rusty, I somehow thought the validation datatype was able to accumulate errors on bind and that we could potentially port over the solution to Kotlin, but I saw the comments on this bindValidation function that say in other words what you just said above.