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

Experiment with allowing empty inline records #6494

Merged
merged 7 commits into from
Nov 27, 2023
Merged

Conversation

zth
Copy link
Collaborator

@zth zth commented Nov 25, 2023

No description provided.

@zth zth requested a review from cristianoc November 25, 2023 17:10
@mununki
Copy link
Member

mununki commented Nov 27, 2023

I ask out of curiosity. What usability needs this feature?

@zth
Copy link
Collaborator Author

zth commented Nov 27, 2023

I ask out of curiosity. What usability needs this feature?

Two main things.

First, this TS wasn't possible to express in an idiomatic/non-hacky way previous to this:

type result = {kind: "success"} | {kind: "failed", reason: string}

It can now be expressed as:

@tag("kind")
type result = | @as("success") Success({}) | @as("failed") Failed({reason: string})

The other part is that we already allow empty regular records, so allowing inline empty records is cohesive with that.

@mununki
Copy link
Member

mununki commented Nov 27, 2023

Thanks for the explanation. Great to have it.

@zth zth force-pushed the allow-empty-inline-record branch from 64c7ca4 to f67174d Compare November 27, 2023 08:55
@cristianoc cristianoc marked this pull request as ready for review November 27, 2023 08:55
@zth zth merged commit c1b9701 into master Nov 27, 2023
@zth zth deleted the allow-empty-inline-record branch November 27, 2023 09:42
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