Add CancellableEffect typeclass. Use it to give races to IO#984
Conversation
Codecov Report
@@ Coverage Diff @@
## master #984 +/- ##
===========================================
- Coverage 47.03% 46.4% -0.64%
+ Complexity 694 692 -2
===========================================
Files 320 320
Lines 8091 8255 +164
Branches 848 859 +11
===========================================
+ Hits 3806 3831 +25
- Misses 3942 4080 +138
- Partials 343 344 +1
Continue to review full report at Codecov.
|
|
@raulraja ready for review! |
| } | ||
| } | ||
|
|
||
| fun <A, B, C, D> IO.Companion.raceN(ctx: CoroutineContext, a: IO<A>, b: IO<B>, c: IO<C>, d: IO<D>): IO<Either<Either<A, B>, Either<C, D>>> = |
There was a problem hiding this comment.
Hoping these would make it to a Concurrent type class in the near future.
| import arrow.Kind | ||
| import arrow.core.Either | ||
|
|
||
| interface CancellableEffect<F> : Effect<F> { |
There was a problem hiding this comment.
I believe this should be just Concurrent and include the race style algebra combinators in this type class so they are available for all concurrent effects in the spirit that concurrent effects are cancelable. For what is worth in cats we have:
Concurrent[F] extends Async[F]
ConcurrentEffect[F] extends Concurrent[F] with Effect[F]
raulraja
left a comment
There was a problem hiding this comment.
This is definitely an improvement from what we have but I'm missing the type class aspect of race, etc.. which should live in my opinion in Concurrent just above Async in a similar way to how it's done in cats-effect
This PR races two IOs, allowing cancellation between them.
It also adds the typeclass CancellableEffect, that was needed to achieve this.