-
-
Notifications
You must be signed in to change notification settings - Fork 0
[Repo] res-to-affine partial-port mode: switch→match / function translation + module-qualified references #488
Copy link
Copy link
Open
Labels
enhancementNew capability or improvement to existing behaviourNew capability or improvement to existing behaviourfeeds:valence-shellFeeds valence-shell's proofs/engineering (D127): judge progress by what it contributes thereFeeds valence-shell's proofs/engineering (D127): judge progress by what it contributes theremigrationPorting between languages or toolchains (e.g. -> AffineScript)Porting between languages or toolchains (e.g. -> AffineScript)priority:p2Normal - queue itNormal - queue itscope:repoConfined to this repositoryConfined to this repositorystatus:readyFully specified and ready to be picked upFully specified and ready to be picked up
Description
Activity
Metadata
Metadata
Assignees
Labels
enhancementNew capability or improvement to existing behaviourNew capability or improvement to existing behaviourfeeds:valence-shellFeeds valence-shell's proofs/engineering (D127): judge progress by what it contributes thereFeeds valence-shell's proofs/engineering (D127): judge progress by what it contributes theremigrationPorting between languages or toolchains (e.g. -> AffineScript)Porting between languages or toolchains (e.g. -> AffineScript)priority:p2Normal - queue itNormal - queue itscope:repoConfined to this repositoryConfined to this repositorystatus:readyFully specified and ready to be picked upFully specified and ready to be picked up
Proposal
Successor to #57 (now closed — its goal, the
.res→.affinedeclaration translator, is delivered). This issue tracks the next translation model fortools/res-to-affine/: a partial-port mode that translates expression- and function-level constructs, plus module-qualified references.Why a separate issue / model
--translatetoday guarantees that every emitted form type-checks standalone (main.exe check→ Type checking passed), which is exactly why it's bounded to self-contained top-level declarations: type aliases, sums, structs, generics, and literallet→const(slices delivered in #477 / #481 / #484). Two remaining forms cannot meet that guarantee by construction and need a different model:1.
switch→match(+ function translation) — partial-port modeA
matchis an expression, only meaningful inside a function body. Producing a type-checkable result means translating the whole enclosing function — but ReScript bindings are usually un-annotated (let f = x => …), while AffineScriptfnrequires parameter and return types, so the output won't compile.The model this needs is translate-with-TODO-holes: render the structural skeleton of a function (signature stub +
matcharms with translated patterns) and leave un-inferable bodies / types as explicit// TODOislands. This drops the standalone-type-check guarantee — output is a partial port a human finishes, matching the README's original "~60–80% translation" vision. Scope to design:switch e { | P => body, … }→match e { P => body, … }(pattern translation;=>kept; leading|dropped; commas added)2. Module-qualified references
Belt.Map.tnow parses (the #228 grammar gap closed —parser.mly:515wiresqualified_type_nameintotype_expr_primary) butBelt::Map::Twon't resolve against a target module that doesn't exist yet. Needs a module-mapping story (ReScript stdlib module → AffineScript stdlib module, or an explicit "unresolved import" marker) before it can be emitted without breaking a build.Acceptance / starting points
tools/res-to-affine/walker.ml) and the conservative skip-don't-guess discipline.walker-phase3*suites (skip without the tree-sitter grammar).Context
Pkg.Type/Pkg.Effectunrepresentable (estate-wide port blocker; ADR-014) #228.tools/res-to-affine/README.md§"Scope boundary — what--translatewill not do".Filed as the successor to #57 at the owner's request.