feat: report better types in API for embeddings #1068
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For embeddings, (i.e. where we have both a checked-at and synthesised type), we must (with the current API design) choose one type to report as the type of the selection. Previously we chose the synthed, but we now:
Note that these two types must be consistent. Consider the situation where we are checking
T ∋ e
and discover thate ∈ S
. If we did not haveT ~ S
, then this would be a type error, which smartholes would rectify by puttinge
in a non-empty hole, givingT ∋ {? e ?} ∈ ?
and? ∋ e ∈ S
. In this case, we report that{? e ?}
has typeT
ande
has typeS
.The most obvious place that this change will affect is asking for the type of an expression hole: these synthesise the hole type, but may be in a checkable context. We now report the type the context requires them to have, rather than a hole. However, there are other situations, such as (assuming
swap ∈ ∀a b . Pair a b -> Pair b a
)swap @Int @? (swap @Char @? ?)
where the innerswap
is checked atPair Int ?
and synthesisesPair ? Char
.