-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add cats.Parallel instance for Future #132
[WIP] Add cats.Parallel instance for Future #132
Conversation
So travis-ci says I'm not familiar with your workflow here, so if I need to PR on something other than |
@felixbr I think that's a Travis CI JVM thing—they've been phasing out Oracle JDK 8 and I guess it hadn't hit this repo before now. If you change the Travis config to |
(I'll review tomorrow—thanks for doing this!) |
Codecov Report
@@ Coverage Diff @@
## master #132 +/- ##
=========================================
+ Coverage 93.8% 93.91% +0.1%
=========================================
Files 4 5 +1
Lines 113 115 +2
Branches 3 3
=========================================
+ Hits 106 108 +2
Misses 7 7
Continue to review full report at Codecov.
|
Sorry, lost track of this… |
|
||
/** INTERNAL API — Newtype encoding for types with one type parameter. | ||
* | ||
* The `Newtype1` abstract class indirection is needed for Scala 2.10, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't support 2.10, so couldn't these go directly on FuturePar
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I'll take a look at it again
No worries, I thought you were busy with your new job 😄 |
Merging this now—we can look at the newtype encoding in a follow-up. |
Hi,
this is a first attempt at adding a
cats.Parallel
instance (see #90).Since I'm mostly familiar with
Future
and notRerunnable
I implemented it forFuture
first and if that is done I can maybe try to replicate it forRerunnable
.I based the implementation on the implementations for
cats.effect.IO
andmonix.eval.Task
as I know those libraries reasonably well.I consider this PR WIP as I have some questions:
I reused the Newtype concept present in
cats-effect
andmonix
. Both have an Apache2.0 license, so I'm not sure how attribution for this piece of code works. Maybe we can just use it, maybe we need to keep the copyright header, I'm not too familiar how this works, sorry.I put the tests next to the existing ones for
Future
. AsArbitraryInstances
doesn't haveFuturePar
in scope I couldn't move the instances there. For the moment they are in theFutureSuite
, but if you don't like this I can put more time into finding a scoping solution to extract it.The elephant in the room is the fact that
ap
andproduct
on the normalFuture
instance are already defined in terms ofFuture.join
, so they run things in parallel already. This meanstraverse
andparTraverse
as well assequence
andparSequence
will all be parallel. This is in line with the behavior of instances ofscala.concurrent.Future
iirc.There is the option to change
traverse
to be sequential, butsequence
cannot be sequential (afaik), so this would be awkward and besides that it'd also be a breaking change.I'd argue that
parTraverse
andparSequence
still have the benefit of explicitly signaling the reader how they will execute, even if they don't necessarily bring new functionality to the table.Hope this is reasonable. Looking forward to your feedback :)
Cheers
~ Felix