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

Hygiene problems when ops-eligible methods refer to type members of type class #32

Open
mpilquist opened this issue Sep 8, 2015 · 1 comment

Comments

@mpilquist
Copy link
Member

Some examples:

// Fails to compile
@typeclass trait F[A] { self =>
  type B = A
  def f(a: A): Option[B]
}

// Fails to compile
@typeclass trait G[A] { self =>
  type B = A
  def f(a: A): Option[self.B]
}

// Compiles but doesn't generate an op for f
@typeclass trait H[A] { self =>
  type B = A
  def f(b: B): Option[A]
}
@mpilquist mpilquist changed the title Hygiene problems when extension methods refer to type members of type class Hygiene problems when ops-eligible methods refer to type members of type class Sep 8, 2015
@paulp
Copy link
Contributor

paulp commented Mar 8, 2017

I looked at this, and it's pretty well hopeless for the same reason as #55.

// Method should only be adapted if the first parameter in the first parameter list
// matches `tparamName`
val TargetTypeName = tparamName

It's not possible to generate correct code when correctness depends on knowing how names are bound but ad hoc string matching is being used to attempt to approximate that.

Your best bet is to severely restrict how people can write their type classes so the necessary information can be obtained before typechecking.

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

No branches or pull requests

2 participants