-
Notifications
You must be signed in to change notification settings - Fork 1.1k
MatchType does not reduce for GADT aliases #6687
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
Assigning to @OlivierBlanvillain and @AleksanderBG since it touches both match types and GADTs. |
I am trying to write a safe printf using the new shiny dependent tools on dotty, and I was redirected here after posting on gitter, I hope it is a helpful example: enum Format {
case FInt[T <: Format](t: T)
case FString[T <: Format](t: T)
case FOther[T <: Format](other: Char, t: T)
case FEnd()
}
type InterpretFormat[F <: Format] =
F match {
case Format.FInt[t] => Int => InterpretFormat[t]
case Format.FString[t] => String => InterpretFormat[t]
case Format.FOther[t] => InterpretFormat[t]
case Format.FEnd => String
}
def toFunction[F <: Format](format: F, acc: String): InterpretFormat[F] =
format match {
case Format.FInt(t) => (i: Int) => toFunction(t, acc + i.toString)
case Format.FString(t) => (s: String) => toFunction(t, acc + s)
case Format.FOther(other, t) => toFunction(t, acc + other.toString)
case Format.FEnd() => acc
} This gives a compilation error like this one for each line on the pattern matching of the
|
BTW I am planning a presentation around this... with all kindness may I ask, what is the plan with this limitation? |
@FrancoAra We still haven't decided on a plan, which means it won't be for the near future. |
Thank you for your response @OlivierBlanvillain :) it is a shame to hear that though |
Fix #6687: handle gadt bounds in match type reduction
This gives:
If I swap the two cases in the match type the error is on the next line. This seems to indicate that the problem is in the no-overlap checks for match types. Maybe it needs to be strengthened for GADT aliases.
Generally:
The text was updated successfully, but these errors were encountered: