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

Introduce application syntax for ADTs #1825

Merged
merged 1 commit into from
Feb 23, 2024
Merged

Conversation

yannham
Copy link
Member

@yannham yannham commented Feb 20, 2024

Now that typechecking, pattern matching and core contracts are implemented for ADTs (enum variants), we switch from the temporary to the final syntax, which is just to use the same application syntax as for function application.

There was an unforeseen ambiguity: function argument patterns can be chained for multi-ary function, for example fun {x,y} {z} => x + y + z. This would clash with unparenthesized enum variants: fun 'Foo 'Bar => could be either fun ('Foo) ('Bar) or fun ('Foo 'Bar).

This PR chooses the first one: for a top-level function pattern argument, we only allow parenthesized enum variants such as fun ('Foo 'Bar). Thus fun 'Foo 'Bar => is necessarily fun ('Foo) ('Bar). The rationale being that it's more in line with other patterns, where each top-level space delimit function arguments, as in fun x y, fun {x} {y}, etc.

Doing so, we apply the same restriction to nested enum variants, to forbid patterns like let 'Foo 'Bar 'Baz = x, which could be parsed unambiguously as 'Foo ('Bar 'Baz), but are quite confusing.

@yannham yannham requested review from jneem and vkleen February 20, 2024 14:36
@github-actions github-actions bot temporarily deployed to pull request February 20, 2024 14:40 Inactive
Now that typechecking, pattern matching and core contracts are
implemented for ADTs (enum variants), we switch from the temporary to
the final syntax, which is just to use the same application syntax as
for function application.
@github-actions github-actions bot temporarily deployed to pull request February 21, 2024 11:25 Inactive
@yannham yannham added this pull request to the merge queue Feb 23, 2024
Merged via the queue into master with commit 20809d3 Feb 23, 2024
5 checks passed
@yannham yannham deleted the syntax/adt-application branch February 23, 2024 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants