feat(res-to-affine): partial-port mode — --partial fn skeletons + switch→match (Refs #488)#494
Merged
Merged
Conversation
…tch->match (Refs #488) 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 #488 https://claude.ai/code/session_017T8SzHr2yXav8hm4Ho76Uw
This was referenced May 31, 2026
feat(res-to-affine): #488 partial-port slice 2 — pipe desugaring + if/else + blocks (Refs #488)
#495
Merged
🔍 Hypatia Security ScanFindings: 83 issues detected
View findings[
{
"reason": "Action perpolymath/standards/.github/workflows/governance-reusable.yml@main\n needs attention",
"type": "unpinned_action",
"file": "governance.yml",
"action": "pin_sha",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Action ons/checkout@v6\n needs attention",
"type": "unpinned_action",
"file": "publish-jsr.yml",
"action": "pin_sha",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Action land/setup-deno@v2\n needs attention",
"type": "unpinned_action",
"file": "publish-jsr.yml",
"action": "pin_sha",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in affine-vscode-publish.yml",
"type": "missing_timeout_minutes",
"file": "affine-vscode-publish.yml",
"action": "flag",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in casket-pages.yml",
"type": "missing_timeout_minutes",
"file": "casket-pages.yml",
"action": "flag",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in casket-pages.yml",
"type": "missing_timeout_minutes",
"file": "casket-pages.yml",
"action": "flag",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in ci.yml",
"type": "missing_timeout_minutes",
"file": "ci.yml",
"action": "flag",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in ci.yml",
"type": "missing_timeout_minutes",
"file": "ci.yml",
"action": "flag",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in ci.yml",
"type": "missing_timeout_minutes",
"file": "ci.yml",
"action": "flag",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in ci.yml",
"type": "missing_timeout_minutes",
"file": "ci.yml",
"action": "flag",
"rule_module": "workflow_audit",
"severity": "medium"
}
]Powered by Hypatia Neurosymbolic CI/CD Intelligence |
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.
What
First slice of #488 — a
--partialflag implementing the partial-port model: a distinct mode from--translatewhose output is a skeleton a human finishes and deliberately does not type-check (un-annotated ReScript functions can't yield a compilable AffineScriptfn) — but it parses.Renders each module-top-level
let f = (params) => bodyintofn f(params: _) -> _ { … }:--partial)let area = (w, h) => w *. hfn area(w: _, h: _) -> _ { w * h }let classify = x => switch x { | Some(n) => n + 1 | None => 0 }fn classify(x: _) -> _ { match x { Some(n) => n + 1, None => 0, } }let greet = name => "hi " ++ namefn greet(name: _) -> _ { "hi " ++ name }let piped = x => x->doStuff(1)fn piped(x: _) -> _ { () /* TODO: x->doStuff(1) */ }How
switch→matchwith variant / tuple / literal pattern translation; arm bodies translated (unwrappingsequence_expression/expression_statement).+./*.→+/*and===/!==→==/!=),++concat, member + module-qualified access, ternary →if/else. The binary operator is an anonymous token in the ReScript grammar, so it's sliced from source between the operands._; un-translatable expr/pattern →() /* TODO *//_ /* TODO */, so the output still parses.translate_expr/translate_switch(mutually recursive) +translate_pattern+partial_function+collect_partial+Walker.translate_partial; emitter gainsemit_partial;maingains--partial(precedence over--translate, walker-only).--translateand its declaration model are untouched.Verification (local, apt-bootstrapped toolchain)
dune builddune runtest tools/res-to-affine/990214amain.exe checkon the generated skeletonScope / next under #488
First slice. Deferred: pipe desugaring (
a->f(b)→f(a, b)),if/block-bodied functions, combining--partialwith--translate, and module-qualified-reference resolution (module-mapping). Documented in the README's updated scope-boundary + new--partialsection.Refs #488https://claude.ai/code/session_017T8SzHr2yXav8hm4Ho76Uw
Generated by Claude Code