I'm doing a simple exercise from the book Advanced scala with cats on my own.
I want to use Cartesian with Validated.
/*
this works
*/
type ValidatedString = Validated[ Vector[String], String]
Cartesian[ValidatedString].product(
"a".valid[Vector[String]],
"b".valid[Vector[String]]
)
/* this doesnt work*/
type Result[A] = Validated[List[String], A]
Cartesian[ValidatedString].product(
f(somevariable)//returns Result[String],
g(somevariable)//returns Result[Int],
).map(User.tupled) // creates an user from the returned string, int
Im completely clueless. Any hints ? Im getting :
could not find implicit value for parameter instance: cats.Cartesian[Result]
Cartesian[Result].product(
^
ValidatedStringin terms ofVector[], while in the second example, you define it in terms ofList[]. Is this a real difference? - Bob DalgleishValidatedStringisn't a type constructor. It would make this question more useful to future readers to make sure that your code is described correctly. - Travis Brown