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

Ast async #7223

Merged
merged 4 commits into from
Jan 8, 2025
Merged

Ast async #7223

merged 4 commits into from
Jan 8, 2025

Conversation

cristianoc
Copy link
Collaborator

@cristianoc cristianoc commented Jan 2, 2025

Prepare for ast async cleanup:

  • Refactor code for "@res.async" payload handling
  • Clean up handling of type and term parameters: now each => in a function definition corresponds to a function, even when only types are present. So e.g. (type a) => 3 is now a function just like () => 3.

The question remains on what to do with trailing types in function definitions: (x, type a) => x+1. There's no way currently to represent them cleanly. One could forbid these case or move all the type a before all the term parameters.

Before this diff `() => 3` would be a function but `(type a) => 3` would just be a number.
Plus, `(type a) => (type b) => (x) => ...` would express a single function.
Now, each `=>` represents a function (possibly adding a unit parameter when there are only types but no no term parameters).
Copy link
Collaborator

@zth zth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Is there any difference in practice between a prefixed or trailing term type?

@cknitt
Copy link
Member

cknitt commented Jan 2, 2025

Tested against a real world project without issues. 👍

@cristianoc
Copy link
Collaborator Author

cristianoc commented Jan 7, 2025

Awesome! Is there any difference in practice between a prefixed or trailing term type?

Technically, mixing types and terms provides some restrictions (terms appearing before a type cannot use it). For example, this cannot be typed:

(x, type a, y:a) => x == y

That said, I could not find examples where this restriction is actually useful.
Thinking about having a normalised form (type a b c, x, y, z) => ... where all the types appear at the beginning. Which is the shape that all existing examples take.

In fact, I'm considering to treat types as if they were all in the beginning anyway, and reformatting to that form.
One additional side effect of this form, is that we could eventually remove type a as an independent AST node, and instead move all types to the AST node for function definitions. Eventually, (type a b c, x, y, z) could be a single node.

@cristianoc cristianoc merged commit 4982266 into master Jan 8, 2025
20 checks passed
@cristianoc cristianoc deleted the ast-async branch January 8, 2025 09:54
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.

3 participants