Skip to content
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

Async[G] bound on AsyncFunctorK means certain instances are not implementable #144

Open
bpholt opened this issue Aug 21, 2023 · 0 comments

Comments

@bpholt
Copy link
Member

bpholt commented Aug 21, 2023

Including G: Async[G] in the definition of the asyncMapK method:

trait AsyncFunctorK[F[_], G[_]] {
def asyncMapK[Alg[_[_]] : FunctorK](alg: Alg[F])
(implicit AlgR: Alg[ReaderT[F, Alg[F], *]], G: Async[G]): Alg[G]
}

means that any types that cannot implement Async cannot be implemented for AsyncFunctorK either. I'm not sure how important this is, but for example, we can't implement a scala.concurrent.Future ~~> com.twitter.util.Future instance (or the reverse) since neither Async[Future] can be lawfully implemented.

If we'd moved the G[_] : Async context bound to the methods where the existing instances are defined, we'd at least be able to try implementing more instances. For example, at

implicit def scalaFutureAsyncFunctorK[F[_]]: Future ~~> F = new (Future ~~> F) {
override def asyncMapK[Alg[_[_]] : FunctorK](alg: Alg[Future])
(implicit AlgR: Alg[ReaderT[Future, Alg[Future], *]],

F[_] could be F[_] : Async, and the body of the asyncMapK method would remain unchanged.

AFAICT this cannot be changed in a binary-compatible way (applying the usual techniques still results in MiMa detecting a ReversedMissingMethodProblem), and I don't think this possibility is worth introducing a new major version on its own. If we need to release a new major version for some other reason, I'd like to consider including this refactoring as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant