-
Notifications
You must be signed in to change notification settings - Fork 177
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
Typespace::is_nominal_normal_form
#1549
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
1a58abc
to
6c72ede
Compare
18d3ccf
to
c717fb8
Compare
Why do we have both "nominal" and "normal" in the same name? |
...except it would be funnier if it did. I'm going to change this to |
088ad87
to
55cc541
Compare
0ddb997
to
b27d17a
Compare
gefjon
reviewed
Jul 26, 2024
Centril
reviewed
Jul 29, 2024
b27d17a
to
751d9a0
Compare
gefjon
approved these changes
Aug 5, 2024
Centril
reviewed
Aug 5, 2024
dd7bbb1
to
6a3666e
Compare
Centril
reviewed
Aug 5, 2024
Centril
approved these changes
Aug 5, 2024
Add address() and identity() to AlgebraicType
73940b1
to
90edca2
Compare
Centril
approved these changes
Aug 7, 2024
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.
Description of Changes
Introduces a notion of "nominal normal form" for
Typespace
s, which requires thatSum
andProduct
types always be referred to viaRef
s. The intention is that this lets us validate that theTypespace
is in a format that makes sense for performing codegen in a nominal language, where eachRef
corresponds to a fresh type. (Or type alias, if theRef
points to aRef
.)This is used in my upcoming module validation PR. Note that in a module, we also have names attached to these slots via
MiscModuleExport
, but this code doesn't care about that.The module bindings should automatically produce
Typespace
s satisfying this requirement.We could strengthen this in various ways:
Ref
s.Builtin
is referred to by at most one ref.AlgebraicType::unit
andAlgebraicType::never
would then be in a slightly odd place, because they are rep'd as the empty product/sum. I guess you could say that exactly one empty product should have no type alias, and that one will be treated as the "true" unit type.sats
since most users won't care.Ref
chains, or introduce a method to collapse them. This allows generating code for languages without type aliases.(Please bikeshed the name. Is there a type theory name for this?)
Expected complexity level and risk
1, I mainly just wanna validate that I am checking the right things.
Testing
Added proptests.