How do I convert
val from: ValidationNel[E, ValidationNel[E, T]]
to
val to: ValidationNel[E, T]
while capturing all validation errors?
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.
只是flatMap
, ValidationNel
:
from.flatMap(identity)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.