-
Notifications
You must be signed in to change notification settings - Fork 603
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
Integration with cats Parallel #969
Comments
👍 I like the idea of a parallel instance for any effect. Is there a way we could do this as a newtype so as to avoid the orphan? |
I don't think we can do it for any effect without orphans without
introducing explicit tagging, which would make it moot. I haven't really
thought about it that much yet though
…On 6 Nov 2017 12:37, "Michael Pilquist" ***@***.***> wrote:
👍
I like the idea of a parallel instance for any effect. Is there a way we
could do this as a newtype so as to avoid the orphan?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#969 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHaN7ubDXq-c5NJD_nKa-r7mXjciXTl0ks5szv2PgaJpZM4QTJxG>
.
|
Why can't we do something like: case class Par[F[_],A](value: F[A])
object Par {
implicit def parallelInstanceForEffect[F[_]](implicit F: Effect[F]): Parallel[F, Par[F,?]] = new Parallel[F,Par[F,?]] {
def applicative: Applicative[Par[F,?]] = Par.applicativeInstance
def monad: Monad[F] = F
}
def applicativeInstance[F[_]](implicit F: Effect[F]): Applicative[F] = ...
} |
I'm actually thinking we will have the same problem regardless of whether we do it for |
I think the only way to avoid an orphan (or in any case something that would require an import to be usable) would be to newtype |
Right, gotcha. |
You're right sadly, Scala can't figure out the |
Another approach would be typelevel/cats-effect#83 |
cats has recently added a Parallel typeclass which relates types such as
Either
andValidation
, and lets you do(fa, fb).parMap(foo)
, which will use the "related" Applicative, while keeping consistent<*>
andflatMap
, and without requiring any explicit tagging by the user.This gives us an opportunity to provide an Applicative Api in addition to
start
for parallelF
(I likestart
so I want to keep it regardless). Should we:F[_]: Effect
. This will be an orphan so perhaps unadvisable, but it will mean we can removeparSequence
andparTraverse
(already defined for everyParallel
)Parallel[IO, ParIO]
instanceMore info on Parallel: typelevel/cats#1837
The text was updated successfully, but these errors were encountered: