[#336] Replace closure and function type syntax with fn() unified syntax#339
Merged
milkyskies merged 2 commits intomainfrom Mar 17, 2026
Merged
[#336] Replace closure and function type syntax with fn() unified syntax#339milkyskies merged 2 commits intomainfrom
milkyskies merged 2 commits intomainfrom
Conversation
Unified closure and function type syntax under the fn keyword: - Closures: |x| expr -> fn(x) expr, || expr -> fn() expr - Async closures: async |x| expr -> async fn(x) expr - Function types: (T) -> R -> fn(T) -> R, () -> () -> fn() -> () Parser: fn( in expression context is a lambda, fn name( is a declaration. Removed is_function_type/scan_for_rparen_followed_by heuristics since fn keyword now unambiguously starts function types. Updated all .fl files, test fixtures, example apps, inline test strings, formatter, and lowering to use new syntax. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- design.md: all syntax tables, examples, token table, banned tokens - llms.txt: closure syntax, function types, compilation examples - site docs: 13 pages updated (guide, reference, tooling) - tree-sitter: grammar.js pipe_lambda and function_type rules - TextMate: lambda patterns updated for fn() syntax - VSCode: added closure snippet - Neovim: highlights synced with tree-sitter - Lexer: VerticalBar doc comment no longer mentions lambda delimiters 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 #336
Summary
|x| expr→fn(x) expr,|| expr→fn() exprasync || expr→async fn() expr(T) -> R→fn(T) -> R,() -> ()→fn() -> ()fn) for declarations, types, and closures — zero ambiguity||is now only boolean OR,|is now only union typesChanges
Compiler (parser, lowering, formatter):
fn((lambda) vsfn name((declaration) in expression contextis_function_type/scan_for_rparen_followed_byheuristics —fnkeyword is unambiguousfn(...)syntax)instead of|All .fl files: fixtures, todo-app, store example — 25 files updated
Docs: design.md, llms.txt, 13 site pages
Syntax highlighting: tree-sitter grammar, TextMate, Neovim queries, VSCode snippet
Test plan
cargo fmtcleancargo clippy -- -D warningscleanRUSTFLAGS="-D warnings" cargo testclean🤖 Generated with Claude Code