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

Put constructor tags behind a reference in num-scott adt encoding #512

Closed
developedby opened this issue May 27, 2024 · 0 comments · Fixed by #518
Closed

Put constructor tags behind a reference in num-scott adt encoding #512

developedby opened this issue May 27, 2024 · 0 comments · Fixed by #518
Assignees
Labels
compilation Compilation of terms and functions to HVM enhancement New feature or request

Comments

@developedby
Copy link
Member

Currently, constructors are encoded using a numeric tag to differentiate between them:

type Option = (Some val) | None
# becomes
Option/Some = @val @x (x 0 val)
Option/None = @x (x 1)

This works well, but it's hard to disambiguate the result of a program.
Without changing behaviour, we could put each tag behind a unique reference, that way we still get their names at the end, and we could possibly use that to rebuild the constructors during readback.

type Option = (Some val) | None
# could be
Option/SOME = 0
Option/NONE = 1
Option/Some = @val @x (x Option/SOME val)
Option/None = @x (x Option/NONE)

This has the drawback of making pattern matching take 1 extra dereference interaction.

@developedby developedby added enhancement New feature or request compilation Compilation of terms and functions to HVM labels May 27, 2024
@imaqtkatt imaqtkatt self-assigned this May 27, 2024
github-merge-queue bot pushed a commit that referenced this issue May 28, 2024
…ehind-a-reference-in-num-scott-adt-encoding

#512 Put constructor tags behind a reference in num scott adt encoding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compilation Compilation of terms and functions to HVM enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants