Repository navigation
Nicer inferred and displayed record types - #6305
Merged
Merged
Conversation
In general, try to avoid showing slack row variables in most types, similar to what we do for hiding ability variables when in strictly negative position.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Similar to what we do for ability variables, this PR generalizes function signatures to include slack variables in record types, while eliding them from display when they are in strictly negative position. The goal here is to:
For instance, given:
The typechecker treats this as:
... allowing it to be called with
foo {x : 10, blah : "unused" }.But since this
| restis in strictly negative position and appears only once in the type, it is hidden.The
...syntax is gone, it isn't necessary anymore.I futzed with various ways of doing this before settling on this combination. I am not 100% sold this is the right balance, but it's easy to tweak the approach later, so I plan on merging and we can see how it goes.
One thing I rejected, after talking it over with @ChrisPenner - general subtyping of records, where a record is a subtype of another if it has a superset of the fields. That has some bad properties, like that
{x : 10} === {x : 10, y: 11}and if you put differently typed records in a list it just silently infers their least upper bound of common fields, which could even be the empty record type!Tested by transcripts.