Skip to content

Simplify curried function calls to use uncurried syntax - #12

Merged
vbergeron merged 2 commits into
mainfrom
claude/determined-pasteur-96rgdu
Sep 23, 2026
Merged

vbergeron merged 2 commits into
mainfrom
claude/determined-pasteur-96rgdu

Conversation

@vbergeron

Copy link
Copy Markdown
Owner

Summary

This PR simplifies function call patterns across the codebase by leveraging the VM's support for uncurried (multi-argument) function calls, eliminating the need for manual currying and intermediate VmCallable values.

Changes

  • examples/eval/src/main.rs: Removed the call3 helper function that manually curried a 3-argument function call. Replaced with a direct vm.call_global(funcs::TEST_ADD, (a, b, fuel)) call, which the VM now handles as a single uncurried operation.

  • examples/fsm/src/main.rs: Simplified run_step to call STEP as a 2-ary uncurried function directly instead of currying it into two separate calls (call_global followed by call_closure). Removed the now-unused VmCallable import.

  • examples/eval/eval.scm: Added the unshift helper function to complement the existing shift function, enabling proper variable index adjustment during beta reduction. Updated the beta function to use unshift for correct substitution semantics.

Implementation Details

The VM already supports passing multiple arguments to call_global, which internally handles the uncurrying. This change makes the call sites cleaner and more direct, reducing boilerplate while maintaining the same functionality. The Scheme changes ensure correct de Bruijn index management during lambda application.

https://claude.ai/code/session_011Vsc7gM2NbYCYBxR6BsFqG

ds_uncurry compiles `lambdas (a b ...)` definitions into multi-argument
functions, so a single-argument call_global now runs the body with
missing arguments instead of returning a partial closure. The eval
example failed decoding that result as a closure, and fsm hit a match
failure. Pass all arguments in one call_global instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Vsc7gM2NbYCYBxR6BsFqG
beta computed shift(+1, subst(0, shift(+1, arg), body)), but de Bruijn
beta reduction needs a downward shift after substituting, to account
for the removed binder. Free variables drifted upward, so read_church
never recognized a numeral and every test_add reported "timeout". Add
an unshift and use it in beta; church 1+1, 1+2 and 2+2 now evaluate to
2, 3 and 4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Vsc7gM2NbYCYBxR6BsFqG
@vbergeron
vbergeron force-pushed the claude/determined-pasteur-96rgdu branch from e3b94a9 to a369192 Compare September 23, 2026 10:20
@vbergeron
vbergeron merged commit 82ba1a3 into main Sep 23, 2026
2 checks passed
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