How to flatten a sequence of cats' ValidatedNel values
问题 I need to flatten a sequence of cats.data.ValidatedNel[E, T] values to a single ValidatedNel value: val results: Seq[cats.data.ValidatedNel[E, T]] = ??? val flattenedResult: cats.data.ValidatedNel[E, T] I can do it like this: import cats.std.list._, cats.syntax.cartesian._ results.reduce(_ |@| _ map { case _ => validatedValue }) but wonder if a pre-defined library methods exists. 回答1: It depends on how you want to combine them (what is validatedValue in your question ?) import cats.data.