Does Arrow have something equivalent to Parallel i...
# arrow
j
Does Arrow have something equivalent to Parallel in Cats, that abstracts over Monads but also supports parallel composition?
s
So such an abstraction currently doesn’t exist
What is your use-case?
j
@simon.vergauwen No use case. I attended the 47 Degrees Academy session today on "Functional Error Handling and Validation with Cats" and Parallel was mentioned. I was just curious if such a thing existed in Arrow.
👍 1
p
Isn’t that our Concurrent?
s
Not really. Cats exposes
Parallel
to describe a relationship between two
F
. For Concurrent that’d be
IO
<~>
IO.Par
, but it also has an instance for
EitherNel
<~>
ValidatedNel
.
Copy code
interface Parallel<F, G> {
  val applicative: Applicative<G>
  val transform: FunctionK<F, G> 
  val back: FunctionK<G, F>

  fun parTupledN(fa: Kind<F, A>, fb: Kind<F, B>): Kind<F, Pair<A, B>> = 
     back(applicative.mapN(transform(fa), transform(fb)))
}
Conceptually something like this.
👍🏼 3