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
Phases 1/2 of the .res→.affine migration assistant only *mark* anti-patterns.
This begins Phase 3 (partial translation): a new `--translate` flag renders the
two most mechanical, module-qualified-path-independent forms into compilable
AffineScript, inline in the skeleton:
type userId = int -> type UserId = Int
type color = Red | ... -> type Color = | Red | Green | Blue
type shape = Circle(float) -> type Shape = | Circle(Float) | Rect(Int, Int)
Everything else stays a TODO island (markers + quoted original), so nothing is
lost. The translator is conservative by construction — type parameters/generics,
qualified paths, record bodies, non-primitive references, GADT return
annotations, and variant spreads are skipped rather than guessed, so output is
always compilable. Lower-case ReScript type names are capitalised because in
type position lib/parser.mly reads a lower_ident as a type *variable* (TyVar),
only an upper_ident as a TyCon.
Implementation walks the existing Phase-2c tree-sitter AST (node names pinned to
rescript-lang/tree-sitter-rescript@990214a), so it is walker-only; with
--engine=scanner the flag is a no-op. Detection keys on node type rather than
field labels, so it is robust to the grammar's optional alias/body field
ambiguity, and any node-name drift degrades to "skip", never a bad rewrite.
- walker.ml: translate_* + collect_translations + Walker.translate (shared
parse_file; scan refactored onto it, behaviour unchanged)
- emitter.ml: Emitter.emit_translation (proper `module Name;` header with the
required semicolon; emit/skeleton path untouched, snapshot stable)
- main.ml: --translate flag, walker-only wiring, refreshed docstring
- test: fixtures/phase3.res + 5 gated walker tests (count + each shape + the
generic/qualified/non-type forms it must skip)
- README + CHANGELOG: document the slice and what is deferred
Refs #57https://claude.ai/code/session_017T8SzHr2yXav8hm4Ho76Uw
0 commit comments