Skip to content

Dealias type when type parameters inference occurs #23242

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Alex1005a
Copy link
Contributor

The code below displays the type parameter [Res] =>> TypeAl[F, String, Res] for the toFunctorOps implicit conversion.

import cats.Functor
import cats.syntax.all.*

type Result[F[_], Err, Res] = F[Either[Err, Res]]

def test[F[_]: Functor](x: Result[F, String, Int]) = {
  x.map(identity) // error here
}

To fix this, you can do dealias if the type before dealias does not have the same arity as the constructor with which unification occurs, but the type after dealias does have the same arity. Then the type parameter F will be inferred.

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

Successfully merging this pull request may close these issues.

1 participant