[#340] Unify type definition syntax: use {} for all type fields#342
Merged
milkyskies merged 2 commits intomainfrom Mar 18, 2026
Merged
[#340] Unify type definition syntax: use {} for all type fields#342milkyskies merged 2 commits intomainfrom
milkyskies merged 2 commits intomainfrom
Conversation
Records: `type User = { ... }` -> `type User { ... }` (no = needed)
Unions: variant fields use {} instead of (): `| Circle { radius: number }`
Unions wrapped in {}: `type Shape { | Circle { r: number } | Point }`
Newtypes: `type OrderId = OrderId(number)` -> `type OrderId { number }`
Aliases/string unions unchanged: still use =
Parser disambiguates inside {}: | = union, name: = record, bare type = newtype.
Removed is_newtype_constructor heuristic.
Updated all .fl files, test fixtures, example apps, and inline test strings.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- design.md: all type definitions, codegen tables, resolved decisions
- llms.txt: records, unions, newtypes, banned keywords table
- site docs: 10 pages updated (guide + reference)
- tree-sitter: = optional in type_declaration, variant fields use {}
- tree-sitter tests: updated declaration corpus
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #340
Summary
type User = { ... }→type User { ... }(no=needed)type Shape = | Circle(r: number) | Point→type Shape { | Circle { r: number } | Point }type OrderId = OrderId(number)→type OrderId { number }=One syntax for fields:
{ }always means "here are the fields/variants."|inside means union,name: typemeans record.Changes
Compiler:
type Name {goes to newparse_type_body_in_braces()which disambiguates record/union/newtype by peeking at first token inside{}{ }instead of( )All .fl files: 24 files updated (fixtures, examples, inline test strings)
Docs: design.md, llms.txt, 10 site pages
Syntax highlighting: tree-sitter grammar + tests
Test plan
cargo fmtcleancargo clippy -- -D warningscleanRUSTFLAGS="-D warnings" cargo testclean🤖 Generated with Claude Code