Does Arrow have something equivalent to Parallel in Cats, that abstracts over Monads but also supports parallel composition?
s
simon.vergauwen
06/23/2020, 5:35 PM
So such an abstraction currently doesn’t exist
simon.vergauwen
06/23/2020, 5:36 PM
What is your use-case?
j
julian
06/23/2020, 7:00 PM
@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
pakoito
06/23/2020, 11:10 PM
Isn’t that our Concurrent?
s
simon.vergauwen
06/24/2020, 7:57 AM
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
.
simon.vergauwen
06/24/2020, 8:00 AM
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)))
}