-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
No kind inference for match types #10077
Comments
Maybe I'm misunderstanding your example, but I think the compiler is doing its job properly here. Indeed, your definition of scala> trait Foo {
| type X
| def f(x: X) = ()
| }
|
| class Bar extends Foo {
| type X = List
| def f(x: List) = ()
| }
8 | def f(x: List) = ()
| ^^^^
| Missing type parameter for List |
@OlivierBlanvillain the issue is, it is not possible to declare def f(x: T.Inner[T0][List]): Unit // won't compile It seems that match types are purely syntactical (i.e. no kind infered for match type declaration), which leads to this weird situation |
I see, makes sense, you essentially want something like the following: trait T[F[_[_]]]
object T:
type Inner[x, y[_]] = x match { case T[f] => f[y] }
trait U[T0]:
def f(x: T.Inner[T0, List]): Unit It looks like in your original example, the compiler thinks that |
How about:? trait T[F[_[_]]]
type Inner[x] = [X[_]] =>> x match { case T[f] => f[X] }
trait Monad[F[_]]
type TMonad = T[Monad]
trait U[T0]:
type T0_member = T0
def f(x: Inner[T0][List]): Unit
class X extends U[T[Monad]]:
def f(x: Inner[T0_member][List]): Unit = ??? |
Minimized code
Output
Expectation
I'm trying to use match types as a replacement for scala2 type projections, and it seems that it is not always possible now.
So I expect that it would be possible to define abstract method
f
as follows:The text was updated successfully, but these errors were encountered: