Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scalaz: Convert ValidationNel of ValidationNel to ValidationNel

How do I convert

val from: ValidationNel[E, ValidationNel[E, T]]

to

val to: ValidationNel[E, T]

while capturing all validation errors?

like image 336
silverberry Avatar asked Nov 18 '25 03:11

silverberry


1 Answers

you can use from.fold(Failure(_), identity).

In general, flatMap(identity) or .join works for any Monad for turning F[F[A]] into F[A], however, Validation is not a Monad, and the flatMap / join methods for Validation are deprecated.

like image 111
stew Avatar answered Nov 20 '25 16:11

stew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!