-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Constraint solving of higher-kinded type variables is too coarse #4147
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
Comments
Here's a minimized example: trait Higher[F[_]]
trait Super[A]
trait Sub[A] extends Super[A]
object Test {
implicit def higherSub: Higher[Sub] = ???
implicit def deriv[F[_]](implicit bla: Higher[F]): F[String] = ???
val x: Super[String] = deriv
} To typecheck this we need to solve: ?F[String] <: Super[String] At this point we instantiate To solve this properly we would need a way to constrain the kind of |
Thinking about it more, I wonder if we could constrain the kind of ?F =: [X] => ?F_1[X]
?F_1 <: Foo Then |
Actually, no need for a fresh type variable, we can just set: ?F >: [X] => Nothing <: [X] => Foo[X] |
There seems to be some confusion. I think we have I already suspected you can have |
Hmm right, then you can scratch everything I said above :). |
If my interpretation works, then maybe we could set |
Yes. |
Unfortunately this is currently broken because of the poly-kinded Nothing, we may end up doing something like: ?F[A] <:< Foo[A, B] ?F <:< Foo ?F := Nothing // OK, even though ?F has the wrong kind
Unfortunately this is currently broken because of the poly-kinded Nothing, we may end up doing something like: ?F[A] <:< Foo[A, B] ?F <:< Foo ?F := Nothing // OK, even though ?F has the wrong kind
I've played a bit with this, but this will be annoying to get working properly until we get rid of the poly-kinded Nothing, because currently we can end up instantiating type variables with a wrong kind if we're not careful, see https://github.com/dotty-staging/dotty/commits/fix/hk-constraint |
Wait, if |
Yes, but the problem is that we start with for example: ?F[A] <:< List[A]
?F <:< List At this point we should not instantiate anything and return false because the kind of |
Straight out of scala/bug#10753 (comment)
I don't know if this is the intended behaviour in Dotty, but I'm reporting it just in case. It looks like
F
is instantiated toFoo
in Dotty but not in Scala, which is what scala/bug#10753 is all about. The code above is a counterexample (maybe it can be minimized further).The text was updated successfully, but these errors were encountered: