-
Notifications
You must be signed in to change notification settings - Fork 38
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 sum types in the simulator #1242
Merged
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
changed the title
WIP: Add support for sum types in the simulator
Add support for sum types in the simulator
Nov 10, 2023
This is required in order to support sum type declarations in the REPL. Sum type declarations work like this this: When a type alias for a sum is declared, e.g., `type T = A | B`, the parser expands this into 3 declarations: ``` type T = A | B val A : T = variant("A", {}) val B : T = variant("B", {}) ``` However, the previous implementation the read and eval parts of the REPL took the input read, ran it thru the parser, then took only the *last* declaration, ignoring anything else. As a result, the type annotation sealing the generated operators with the proper sum type was in the context during type checking. This behavior of dropping all but the last declaration is completely unnecessary, so this change generalizes the read and eval to work on any sequence of declarations that are parsed out of the input.
shonfeder
force-pushed
the
1033/sum-types-in-simulator
branch
from
November 10, 2023 04:07
6abf740
to
58984c1
Compare
bugarela
approved these changes
Nov 10, 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, I'm super excited to try it out! I only have some comments on the pluralization of some methods 😄
Thanks for the review and corrections! I fixed the plurals :) |
I am too late with the review. This is amazing :) |
4 tasks
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.
Closes #1033
Adds support for sum types to the compiler (and so the simulator):
input, instead of just the last one (required to enable sum type declarations
to be entered in the REPL).
variants.
The history is clean enough that it would probably help to review by commit.
CHANGELOG.md
for any new functionalityREADME.md
updated for any listed functionality