-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat!: API gives more details on mismatched types #1172
Conversation
This PR works pretty well for terms, but for types it is somewhat lacking: in We also have a more tricky(?) issue with Similarly with the term |
I've pushed a draft commit that does this for kinds, but not types. The remaining cases to consider are "a term hole in SYN position where the typing rule has a |
On further thought, I have decided to not include any inference/constraint propagation in this PR. Mismatches in synthesisable position which nonetheless have constraints will simply say "expected a hole type", e.g. in The reasoning here is
|
0e99a55
to
8b52cff
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.
This is obviously useful even without (some form of) #81, so I agree with merging in its current state, much as some outputs are unsatisfying.
This simply gives more information in the api `selection/` (i.e. `getTypeOrKind` operation). We give both the type assigned to the hole itself as well as the type assigned to the contents. This doesn't actually expose more information, since one could always call the old api on both the hole and its contained node, but it is much more convenient for a consumer to have all the relevant information to understand a mismatch in one place. BREAKING CHANGE: this changes the return type of an endpoint in the openapi. Signed-off-by: Ben Price <ben@hackworthltd.com>
This is implemented by a small change to the metadata assigned by the kindchecker on non-empty holes. `List {? Maybe ?}` now reports "expected `*`, got `* -> *`". However, `{? Nat ?} Bool` still reports "expected `?`, got `*`". This is consistent with the term level where `not {? Zero ?}` reports "expected `Bool`, got `Nat`". `{? Zero ?} True` reports "expected `?`, got `Nat`". Improving this (we may want to report "expected `* -> ?`" and "expected `Bool -> ?`" above) is left as future work, as this is starting to veer into type inference territory, which we have avoided so far. We may further wish to use non-local information to improve our reporting, e.g. `List ({? Nat ?} Bool)` could report "expected `* -> *`" by noting `Bool : *` and `List : * -> *`, and `not ({? Nil ?} Zero True)` could report "expected `Nat -> Bool -> Bool`". Note that if we improve this in future we should probably also report these expected types/kinds for empty holes as well. Signed-off-by: Ben Price <ben@hackworthltd.com>
8b52cff
to
b01a481
Compare
For non-empty holes (aka "mismatches"), the OpenAPI now gives both the expected and actual types. We also record the checked-at kind of non-empty type holes in the metadata rather than the synthesised one, for consistency with the term level.
BREAKING CHANGE: this changes the OpenAPI schema.