-
Notifications
You must be signed in to change notification settings - Fork 19
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
Ill-typed code with schematic polymorphism #130
Comments
Sorry for the long delay with this. I think this is an interesting issue with polymorphism that I remember discussing with Andrew, Gopalan, Yuting the last time I was in Minneapolis. I believe at that point I was convinced that we would need some kind of range restriction for type arguments. However, Yuting ended up implementing a version without the restriction. Maybe this is explained in the paper Yuting and Gopalan wrote about schematic polymorphism? Ping @yvting, @gnadathur97. |
Given a definition, the type variables in its type are schematic over its entire body. Such a schematic definition represents an infinite set of definitions obtained by instantiating the type variables with ground types. The example above can be restated as follows where the scope of type variables is made explicit:
Here, the type variable A ranges over a single clause. Note that in the current implementation we implicitly derive schematic type variables from types and do not allow this form of definitions. This can be changed if people think the explicit syntax will improve readability. With regards to the example, I do not see any ill-typed code. Once Also notice that the constant Finally, because the types of
|
We can write ill-typed code which Abella accepts by using a polymorphic type constructor.
Some definitions to provide types to demonstrate the issue:
The code showing the actual issue:
By using
hideType
to produce atypeHider_c
, we are able to use a term of typeaty
(the variableB
) as the second argument ofhiderHelper
, which is supposed to take a term of typebty
.If Abella disallowed constructors having type variables in argument types which don't appear in the type being built, I don't think it would be possible to build ill-typed code like this. We would not be able to write the
typeHider_c
constructor becauseA
does not occur intypeHider
, andtypeHider_c
is what lets us hide the true type ofB
.The text was updated successfully, but these errors were encountered: