title: Kotlin arrow combine list of validated
body: <p>I have the following classes:</p>
  
  <pre><code>class Person(id: Long, name: String)
  
  sealed class PersonError {
      data class InvalidId(val field: String) : PersonError()
      data class InvalidName(val field: String) : PersonError()
  }
  </code></pre>
  
  <p>As I loop and validate through multiple persons, I get:</p>
  
  <pre><code>List&lt;ValidatedNel&lt;Error, Person&gt;&gt;
  </code></pre>
  
  <p>or: </p>
  
  <pre><code>List&lt;Validated&lt;Error, Person&gt;&gt;
  </code></pre>
  
  <p>How do I transform the above list to:</p>
  
  <pre><code>Validated&lt;Nel&lt;MappingError&gt;, List&lt;Person&gt;&gt;
  </code></pre>
  
  <p>I want to accumulate all errors related to the validation of all persons. This is needed, because I want to do the following:</p>
  
  <pre><code>val vId : ValidatedNel&lt;Error, Long&gt; = validateId(id).toValidatedNel()
  val vPersons : List&lt;ValidatedNel&lt;Error, Person&gt;&gt; = validatePersons(persons).toValidatedNel()
  
  ValidatedNel.applicative&lt;Nel&lt;PersonError&gt;&gt;(Nel.semigroup&lt;PersonError&gt;())
      .map(vId, vPersons) {
          val id = it.a
          val persons = it.b
          Group(id, persons)
      }.fix()
  </code></pre>
  
  <p>The current 'map' does not accept a <code>List&lt;ValidatedNel&lt;Error&gt;, Person&gt;&gt;</code></p>