<https://github.com/arrow-kt/arrow-fx/blob/32d3d45...
# arrow
a
Would that work with
arrow.fx.coroutines
?
p
hmmmm I don’t believe it does
so, nest them for now?
a
Or should I add a PR to expand the arity to 5?
Others might bump into the same issue challenge.
h
As suggested by @pakoito, you can nest multiple calls to parMapN in order to get the arity you need:
Copy code
suspend fun <A, B, C, D, E> parMapN(fa: suspend () -> A,
                                    fb: suspend () -> B,
                                    fc: suspend () -> C,
                                    fd: suspend () -> D,
                                    f: (a:A, b:B, c:C, d:D) -> E) {
  val temp1 = suspend { parMapN(fa, fb, ::identity) }
  val temp2 = suspend { parMapN(fc, fd, ::identity)  }
  parMapN(temp1, temp2) { (t1, t2) -> f(t1.first, t1.second, t2.first, t2.second) }
}
you can also inline temp1 and temp2 and the suspend modifier is inferred:
Copy code
parMapN(
    { parMapN(fa, fb, ::identity) },
    { parMapN(fc, fd, ::identity)  }) { (t1, t2) ->
    f(t1.first, t1.second, t2.first, t2.second)
  }
a
@HieiJ - thanks for the suggestion, that is exactly what I am doing. But the complexity is much higher with that approach.