ChristopherDavenport/cats-par

Implicit conversion to Parallel / deriving Parallel from Par?

Closed this issue · 6 comments

I hit this when trying to get the default instance of Parallel for Kleisli[F, A, ?] (assuming F[_] : Par) - the instance wasn't picked up.

It'd be great to have a way to automatically get the Parallel instance back into the implicit scope.

Currently trying to build a generic workaround (having a Par.Aux provide a Parallel), but it's a diverging implicit expansion because of implicit def fromParallel[F[_], G[_]](implicit P: Parallel[F, G]): Par.Aux[F, G] in object Par...

Okay, it seems to compile if the aux pattern isn't used:
implicit def parToParallel[F[_]](implicit par: Par[F]): Parallel[F, par.ParAux] = par.parallel

So I'm a bit confused. I have that in the package object. So you should have that if you do a bulk import of import cats.temp.par._

I had considered an implicits package but thought the import overhead would be too high.

https://github.com/ChristopherDavenport/cats-par/blob/master/par/shared/src/main/scala/cats/temp/par/package.scala#L6

In the test we have a compile test that ensures we can go back the other direction when desired.

https://github.com/ChristopherDavenport/cats-par/blob/master/par/shared/src/test/scala/cats/temp/par/CompileCheck.scala#L11

Is this the functionality you are looking for or am I misunderstanding.

ah, well, guess I didn't look deep enough to find the thing in the package object :D

Works, closing. Thanks a lot for the whole thing :)