Scalaz: Convert ValidationNel of ValidationNel to ValidationNel

How to convert

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

      

to

val to: ValidationNel[E, T]

      

while capturing all validation errors?

+3


source to share


2 answers


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

.



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

+4


source


Just flatMap

that ValidationNel

:



from.flatMap(identity)

      

+1


source







All Articles