Commit ca0e74e
authored
feat(parser): fn-type with effect arrow in type position (Refs gitbot-fleet#148) (#371)
## Summary
Adds \`fn(A, B) -{E}-> C\` as a type-position production in
\`type_expr_primary\`, mirroring the prefix-row arrow that
\`type_expr_arrow\` and \`return_type\` already accept.
For multi-arg \`fn\`, the row attaches to the **innermost** arrow — that
is where the call actually performs the effect, and it matches the
single-arg case where \`A -{E}-> R\` puts the row on the lone arrow.
Lowering:
\`\`\`
fn(A, B) -{E}-> R ≡ A -> (B -{E}-> R)
\`\`\`
## Why
Required by sustainabot hand-port (gitbot-fleet#148) — \`Router.affine\`
declares \`fn(Http::Request) -{IO}-> Http::Response\` and similar
shapes; the prefix-row form is the natural ergonomic for "a function
that performs effect E".
## Conflict-cost
Zero. The \`FN LPAREN ... RPAREN\` prefix already disambiguates against
every other type-position production, so adding the \`MINUS LBRACE eff
RBRACE ARROW\` continuation here introduces no new lookahead conflict
beyond the existing \`type_expr_arrow\` row-arrow rule it mirrors.
Parser builds with **21 S/R + 1 R/R**, identical to the pre-patch
baseline.
## Test plan
- [x] \`dune build\` green
- [x] Conflict count unchanged: 21 S/R + 1 R/R
- [ ] CI green
- [ ] Smoke: \`fn handle: fn(Http::Request) -{IO}-> Http::Response;\`
parses
## Companion PRs (gitbot-fleet#148 spine)
1. trailing-comma in fn params + expr lists (#370)
2. **this PR** — fn-type with effect arrow in type position
3. builtin/lowercase qualified paths + TOTAL field name
4. lexer \`_\`-prefix idents
5. (hypatia) Levenshtein perf fix
🤖 Generated with [Claude Code](https://claude.com/claude-code)1 file changed
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
544 | 544 | | |
545 | 545 | | |
546 | 546 | | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
547 | 575 | | |
548 | 576 | | |
549 | 577 | | |
| |||
0 commit comments