Skip to content
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 2 commits into from
Aug 7, 2024
Merged

Typespace::is_nominal_normal_form #1549

merged 2 commits into from
Aug 7, 2024

Conversation

kazimuth
Copy link
Contributor

@kazimuth kazimuth commented Jul 25, 2024

Description of Changes

Introduces a notion of "nominal normal form" for Typespaces, which requires that Sum and Product types always be referred to via Refs. The intention is that this lets us validate that the Typespace is in a format that makes sense for performing codegen in a nominal language, where each Ref corresponds to a fresh type. (Or type alias, if the Ref points to a Ref.)

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 Typespaces satisfying this requirement.

We could strengthen this in various ways:

  • Require that all types be referred to via Refs.
    • We could additionally require that each Builtin is referred to by at most one ref.
    • AlgebraicType::unit and AlgebraicType::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.
    • We could introduce new enums for this, possibly in a crate outside sats since most users won't care.
  • Forbid 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.

@kazimuth kazimuth requested review from cloutiertyler and gefjon July 25, 2024 22:33
@kazimuth kazimuth force-pushed the jgilles/new_module_def branch from 1a58abc to 6c72ede Compare July 25, 2024 22:44
@kazimuth kazimuth force-pushed the jgilles/ref_normal_form branch 2 times, most recently from 18d3ccf to c717fb8 Compare July 25, 2024 22:50
@gefjon
Copy link
Contributor

gefjon commented Jul 26, 2024

Why do we have both "nominal" and "normal" in the same name?

@kazimuth
Copy link
Contributor Author

nominal refers to being a normal form that allows codegen for nominal languages. It doesn't mean "all systems nominal".

...except it would be funnier if it did. I'm going to change this to is_nominal.

@kazimuth kazimuth changed the title Typespace::is_in_nominal_normal_form Typespace::is_nominal Jul 26, 2024
@kazimuth kazimuth force-pushed the jgilles/new_module_def branch from 088ad87 to 55cc541 Compare July 26, 2024 19:37
@kazimuth kazimuth force-pushed the jgilles/ref_normal_form branch from 0ddb997 to b27d17a Compare July 26, 2024 19:41
@kazimuth kazimuth changed the base branch from jgilles/new_module_def to master July 26, 2024 19:41
@bfops bfops added the release-any To be landed in any release window label Jul 29, 2024
@kazimuth kazimuth force-pushed the jgilles/ref_normal_form branch from b27d17a to 751d9a0 Compare August 5, 2024 17:04
@kazimuth kazimuth force-pushed the jgilles/ref_normal_form branch from dd7bbb1 to 6a3666e Compare August 5, 2024 20:56
@kazimuth kazimuth added this pull request to the merge queue Aug 6, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Aug 6, 2024
Add address() and identity() to AlgebraicType
@kazimuth kazimuth force-pushed the jgilles/ref_normal_form branch from 73940b1 to 90edca2 Compare August 7, 2024 17:43
@kazimuth kazimuth changed the title Typespace::is_nominal Typespace::is_nominal_normal_form Aug 7, 2024
@kazimuth kazimuth enabled auto-merge August 7, 2024 17:51
@kazimuth kazimuth added this pull request to the merge queue Aug 7, 2024
Merged via the queue into master with commit e3333ea Aug 7, 2024
9 checks passed
@kazimuth kazimuth deleted the jgilles/ref_normal_form branch August 7, 2024 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-any To be landed in any release window
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants