-
Notifications
You must be signed in to change notification settings - Fork 8
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
Do not rely on any explicitness information for inference and constraint resolution #174
Conversation
Always extend the preserve set with FTVs in assertions and opaques
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a good solution to me overall. I think that we should unify the terminology around "preserve"/"bound"/"scope"/"environment" in the code and variable names. For the explicitlyDependent
stuff maybe you should talk to @fedepiz .
PS: what tests are currently failing?
TypeConstraint(ta, tb) | ||
) | ||
) | ||
), preserve - na - nb) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ n
? same in other spots. I wonder if we could also alternatively directly apply the required substitutions (na -> n
and nb -> n
) where necessary and only generate 1 constraint instead of 3 here. Something like:
val n = NatIdentifier(freshName("n"))
decomposed(Seq(TypeConstraint(
substitute.natsInType(ta, Map(na -> n)),
substitute.natsInType(tb, Map(nb -> n))
))), preserve + n)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I was just picking up on that, I will get back to you!
@Bastacyclop Regarding the naming, I think it would make sense to use "typing environment" or "typing context" on the infer side: it is more than a scope, since it has kinding information; it is in line with using "exprEnv" for the expression world, and we are not yet concerned about how this typing environment is used. On the constraints side I would switch to "preserve", since we add and remove things to it regardless of any typing contexts. I added the explicit variables that we create to the preserve set (I think it's best if we leave making any optimizations for later on once the tests pass). There are 13 tests that don't pass, I will send you a file with the results on zulip. Re the dependent types @fedepiz, I tried collecting the identifiers that are made implicit into a set and then subtracting those from the preserve set in lines 133-135, but it didn't seem to help. |
One quick remark about explicit dependence. I have in recent times started to phase it out in my work. and prefer instead throwing the compiler more handwritten constraints until it's happy. That's because it can only infer some marginally more complex situations, but in the end, writing out one type of signature can save your bacon much more reliably. So, if the |
Thomas and I had a meeting and identified some of the possible things that might have been going wrong (there are about 10 test cases that don't pass currently) and talked about a possible roadmap:
|
9d5f13d
to
daafb0f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Maybe we can open relevant issues for the points discussed in #174 (comment) ?
@Bastacyclop will do, thanks for the review! |
I created issues for the first #177 and last #178 points, the rest has been resolved |
Currently we use a global set of type variables to
preserve
, but we still rely on explicitness information to preserve bound variables. Given that we have globally unique variable names we can simply add every bound variable to the set of variables to preserve. Thepreserve
set needs to be modified in recursive calls tosolveOne
(we currently don't have to do that because we use_.asImplicit
on some variables instead).Fragment kinds and matrix layouts are now traversed too and their identifiers are correctly picked up. These identifiers are however ignored by
makeClosed
, because they cannot be bound.IsClosedForm
now correctly traverses lambdas, it used to skip their types.It doesn't seem to make a noticeable impact on the performance of the test suite.