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

Typeclass variance cannot be expressed with language.experimental.modularity Self types #20365

Open
propensive opened this issue May 8, 2024 · 0 comments
Labels
stat:needs triage Every issue needs to have an "area" and "itype" label

Comments

@propensive
Copy link
Contributor

Compiler version

Latest main, 3393f7ea7704eb1dd553c96a805906821c61db5f.

Minimized example

I'm not sure if I've missed a critical detail somewhere, but it's not clear if there's an intended way to support definition-site variance on a typeclass's Self type. (The word "variance" doesn't appear in the documentation, and I don't recall it being discussed during the long discussion about the feature.)

What this seems to mean is that the old-style typeclass and given instance,

trait Foo[-T]:
  def apply(): String

given Foo[Char] = () => "char"

would need its given instance rewritten as,

given [C <: Char] => C is Foo = () => "char"

rather than,

given Char is Foo = () => "char"

in order for summon[Foo['x']] to resolve.

Expectation

I would expect there to be a way to specify the Self type's variance at the typeclass definition site, or for the documentation to offer a solution.

@propensive propensive added the stat:needs triage Every issue needs to have an "area" and "itype" label label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:needs triage Every issue needs to have an "area" and "itype" label
Projects
None yet
Development

No branches or pull requests

1 participant