Skip to content

feat(res-to-affine): #488 partial-port slice 2 — pipe desugaring + if/else + blocks (Refs #488)#495

Merged
hyperpolymath merged 1 commit into
mainfrom
claude/pensive-fermi-JVCzu
May 31, 2026
Merged

feat(res-to-affine): #488 partial-port slice 2 — pipe desugaring + if/else + blocks (Refs #488)#495
hyperpolymath merged 1 commit into
mainfrom
claude/pensive-fermi-JVCzu

Conversation

@hyperpolymath
Copy link
Copy Markdown
Owner

What

Slice 2 of #488 partial-port mode. Extends --partial (built on slice 1, #494) with the three highest-value gaps:

ReScript AffineScript (--partial)
let piped = x => x->doStuff(1) fn piped(x: _) -> _ { doStuff(x, 1) }
let chain = x => x->f->g(2) fn chain(x: _) -> _ { g(f(x), 2) }
let clamp = x => if x > 0 { x } else { 0 } fn clamp(x: _) -> _ { if x > 0 { x } else { 0 } }
let scaled = x => { let y = x + 1; y * 2 } fn scaled(x: _) -> _ { let y = x + 1; y * 2 }
  • Pipe-first -> desugars: a->f(b)f(a, b), a->ff(a). Chains desugar left-to-right for free through the recursion (x->f->g(2)g(f(x), 2)) — ReScript parses pipes left-nested.
  • if/else → AffineScript if c { … } else { … }.
  • Blocks with let statements{ let y = …; y * 2 }; a block function body fills the fn { … } directly (no double braces).

walker: translate_pipe / translate_if / translate_as_block / translate_block(_inner) / translate_block_let added to the expression rec group; partial_function unwraps a block body. Array / record / object literals etc. still become () /* TODO */ holes.

Verification (local, apt-bootstrapped toolchain)

Check Result
full dune build ✅ exit 0
dune runtest tools/res-to-affine/ ✅ 30/30 walker (3 new) against pinned grammar 990214a
parse checkmain.exe check on the skeleton ✅ parses (resolution/type errors only, no parse error)
doc-truthing + no-extension-ts guards ✅ pass

Next under #488

record/array/object literals, labelled args, combining --partial with --translate, and module-qualified-reference resolution.

Refs #488

https://claude.ai/code/session_017T8SzHr2yXav8hm4Ho76Uw


Generated by Claude Code

…/else + blocks (Refs #488)

Extends --partial:
- pipe-first `->`: `a->f(b)` -> `f(a, b)`, `a->f` -> `f(a)`; chains desugar
  left-to-right through the recursion (`x->f->g(2)` -> `g(f(x), 2)`).
- `if`/`else` expressions -> AffineScript `if c { .. } else { .. }`.
- blocks with `let` statements -> `{ let y = ..; y * 2 }`; a block function
  body fills the `fn { .. }` directly (no double braces).

walker: translate_pipe / translate_if / translate_as_block /
translate_block(_inner) / translate_block_let added to the expr rec group;
partial_function unwraps a block body. Array / record / object literals etc.
still become `() /* TODO */` holes.

Verified locally (apt-bootstrapped toolchain): full dune build exit 0; 30
res-to-affine walker tests green (3 new, against pinned grammar 990214a);
`main.exe check` on the generated skeletons parses (resolution/type errors
only, no parse error).

Refs #488

https://claude.ai/code/session_017T8SzHr2yXav8hm4Ho76Uw
@hyperpolymath hyperpolymath marked this pull request as ready for review May 31, 2026 06:47
@hyperpolymath hyperpolymath merged commit 78906f9 into main May 31, 2026
15 of 24 checks passed
@hyperpolymath hyperpolymath deleted the claude/pensive-fermi-JVCzu branch May 31, 2026 06:48
hyperpolymath added a commit that referenced this pull request May 31, 2026
…le (Refs #488) (#499)

STATE.a2ml: dated note documenting res-to-affine --partial partial-port slices 1-3 (#494/#495/#496) + remaining #488 work. .claude/settings.json: allow the _build/default/bin/main.exe compiler oracle. Docs/config only, no code. Refs #488.
@github-actions
Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 83 issues detected

Severity Count
🔴 Critical 2
🟠 High 13
🟡 Medium 68

⚠️ Action Required: Critical security issues found!

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants