I am reading this article
http://typelevel.org/cats/datatypes/validated.html
It says that Validated can be used to do Sequential validations using "andThen" method. This means we stop at the first error and not collect all the errors.
I tried the following code
@ val x = 123.valid[String]
x: Validated[String, Int] = Valid(123)
@ val y = "foo".invalid[Int]
y: Validated[String, Int] = Invalid("foo")
@ x andThen y
cmd4.sc:1: type mismatch;
found : cats.data.Validated[String,Int]
required: Int => cats.data.Validated[?,?]
val res4 = x andThen y
^
Buy why the type mismatch. As you can see both x and y have the same shape.
Edit: Note that I don't want to collect all errors. That I could do easily with x |@| y
. I have validated and I want to process them sequentially.