You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First slice of #488: a NEW --partial flag, a distinct model from --translate.
Its output is a partial port a human finishes and DELIBERATELY does not
type-check (un-annotated ReScript fns can't yield a compilable AffineScript
fn) — but it parses.
Renders each module-top-level `let f = (params) => body` into
`fn f(params: _) -> _ { <translated body> }`:
- switch -> match with variant / tuple / literal pattern translation
- expression translation: literals, identifiers, calls, binary operators
(normalising float ops +. *. -> + * and === !== -> == !=), ++ concat,
member + module-qualified access, ternary -> if/else
- un-inferable types -> `_` holes; un-translatable expr/pattern ->
`() /* TODO */` / `_ /* TODO */` islands, so the result still parses
The binary operator is an anonymous token in the ReScript grammar, so it is
sliced from source between the operands. Walker: translate_expr / translate_switch
(mutually recursive) + translate_pattern + partial_function + collect_partial +
Walker.translate_partial; emitter gains emit_partial; main gains --partial
(precedence over --translate, walker-only).
Verified locally (apt-bootstrapped toolchain): full dune build exit 0; 27
res-to-affine walker tests green (5 new, against pinned grammar 990214a); and
`main.exe check` on the generated skeletons reaches resolution/type-checking
WITHOUT a parse error (the partial-port bar).
Refs #488https://claude.ai/code/session_017T8SzHr2yXav8hm4Ho76Uw
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,7 @@ this project aims to follow [Semantic Versioning](https://semver.org/spec/v2.0.0
20
20
21
21
### Added
22
22
23
+
- feat(res-to-affine): partial-port mode (#488) — new `--partial` flag renders module-top-level functions as AffineScript `fn` skeletons with `switch`→`match` and best-effort expression translation (literals / idents / calls / binary ops with float-op + identity-equality normalisation / `++` / member + qualified access / ternary / variant + tuple + literal patterns); un-translatable forms become `() /* TODO */` / `_ /* TODO */` holes. Output deliberately does NOT type-check but parses (verified). Distinct model from `--translate` (Refs #488)
23
24
- feat(res-to-affine): Phase 3 slice 3 — `--translate` now also lowers module-level `let <id> = <literal>` (int/float/string/bool) to a typed `const name: T = value;`; call / `ref(...)` / destructuring bindings are skipped (not compile-time constants); every emitted form verified compilable via `main.exe check`. `switch`→`match` and qualified-path resolution remain out of the standalone-type-check scope (Refs #57)
24
25
- feat(res-to-affine): Phase 3 slice 2 — `--translate` now also handles record types (→ `struct`) and generics (type params `'a` → `[A]`) across aliases / sums / records; `mutable`/optional-`?` records, qualified paths, and nested generics are still skipped (never guessed); every emitted form verified compilable via `main.exe check` (Refs #57)
25
26
- feat(res-to-affine): Phase 3 slice 1 — `--translate` renders fully-structural type declarations (primitive aliases + simple sum types) into compilable AffineScript; conservative (generics / qualified paths / records / non-primitive payloads are skipped, never guessed); walker-only (Refs #57)
0 commit comments