-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add support for the variant
operator in the type and effect system
#1209
Merged
Conversation
This file contains 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
shonfeder
force-pushed
the
244/sum-types-type-system
branch
from
October 6, 2023 21:16
63cb281
to
3f0e956
Compare
shonfeder
changed the title
244/sum types type system
Add support for the Oct 6, 2023
variant
operator in the type and effect system
bugarela
approved these changes
Oct 17, 2023
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 great! Only very minor comments.
This also requires adding a new constraint `isDefined` that holds iff a type that unifies with the given type is defined in the context.
Allows us to find and transform values from an iterable
- Nullary constructors where being incorrectly defined as lambdas, when they should just be values. - We were not adding the type annotation of the defined type to the operator. But we want this, since in ensures we do not construct open rowed variants and ensures that we have the right topological sorting to ensure the variant constructors are after the defined types.
shonfeder
force-pushed
the
244/sum-types-type-system
branch
from
October 20, 2023 19:46
eed2ee6
to
e9eafd3
Compare
Thanks for the review and for catching my oversights. |
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.
Addresses the first half of #244.
The
variant
operator is the builtin operator introduced in #1206 that injects a value into a sum type. I.e.,type T = A(int) | B; val a : T = variant("A", 42)
.This PR adds support in the type system for checking and inferring the type of this operator.
The most significant change is the introduction of a new constraint
isDefined(t)
which holds when the type schemat
unifies with a defined type. This is required and foretold by the RFC001, approved in #1062. It ensures that users cannot introduces open-rowed variants, since we have decided that the complexity of allowing open, anonymous variant types is undesirable.This PR also corrects the logic around generating the sum type injector operators introduced in #1206.
Please see the commit messages for context. Review by commit my also be helpful.
CHANGELOG.md
for any new functionalityREADME.md
updated for any listed functionality