René's URL Explorer Experiment


Title: Lift the `*.Uncurried` mk wrappers to n-ary function definitions · Issue #227 · purescript-lua/purescript-lua · GitHub

Open Graph Title: Lift the `*.Uncurried` mk wrappers to n-ary function definitions · Issue #227 · purescript-lua/purescript-lua

X Title: Lift the `*.Uncurried` mk wrappers to n-ary function definitions · Issue #227 · purescript-lua/purescript-lua

Description: #226 (issue #198) lifted the run half of the uncurried wrappers: a saturated runFn3 add3 1 2 3 now compiles to add3(1, 2, 3). The constructors stayed opaque FFI, and they undo much of the win. add3 = mkFn3 \a b c -> a + b + c still emits...

Open Graph Description: #226 (issue #198) lifted the run half of the uncurried wrappers: a saturated runFn3 add3 1 2 3 now compiles to add3(1, 2, 3). The constructors stayed opaque FFI, and they undo much of the win. add3...

X Description: #226 (issue #198) lifted the run half of the uncurried wrappers: a saturated runFn3 add3 1 2 3 now compiles to add3(1, 2, 3). The constructors stayed opaque FFI, and they undo much of the win. add3...

Opengraph URL: https://github.com/purescript-lua/purescript-lua/issues/227

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Lift the `*.Uncurried` mk wrappers to n-ary function definitions","articleBody":"#226 (issue #198) lifted the `run` half of the uncurried wrappers: a saturated `runFn3 add3 1 2 3` now compiles to `add3(1, 2, 3)`. The constructors stayed opaque FFI, and they undo much of the win. `add3 = mkFn3 \\a b c -> a + b + c` still emits as `mkFn3(function(a) return function(b) return function(c) ... end end end)`: the wrapper uncurries the call from the outside but re-curries on the inside via `fn(a)(b)(c)`, so every call of a `Fn3` built this way allocates two intermediate closures. The goal is `add3 = function(a, b, c) return a + b + c end`, with zero closures and the `mk*` accessors gone from the emitted FFI tables the same way the `run*` ones went in #226.\n\n## Foreign shapes\n\nFrom the fork FFI (`Data.Function.Uncurried`, `Control.Monad.ST.Uncurried`, `Effect.Uncurried`):\n\n- `mkFn2`..`mkFn10` are `function(fn) return function(a, …, n) return fn(a)…(n) end end`: a multi-parameter function literal wrapping a curried chain;\n- `mkSTFn1`..`mkSTFn10` and `mkEffectFn1`..`mkEffectFn10` are the same shape with a trailing force: `return fn(a)…(n)()`;\n- `mkFn0` wraps a nullary call `fn()` and stays opaque, symmetric with `runFn0`; `mkFn1` and `runFn1` have no foreign at all (they are PureScript-side `id`).\n\n## Approach\n\nExtend the foreign lifter (#178) with two shapes, mirroring how #198 handled the run half, and allowlist `mkFn2`..`mkFn10`, `mkSTFn1`..`mkSTFn10`, `mkEffectFn1`..`mkEffectFn10`:\n\n- A multi-parameter function literal (all parameters named; a vararg declines) lifts to a single n-ary `AbsN`, not to nested unary `Abs`. The nested encoding is exactly the misapplication the lifter's current decline comment warns about. The n-ary `AbsN` codegen already exists (the #24 uncurrying workers emit through it), and the `WellApplied` linter invariant only constrains literal-lambda heads of `AppN`, which this translation does not create.\n- A nullary call `fn()` in an FFI body is the run of an effect thunk. It lifts to an application of `EffectRunArg`, so `isEffectRun` recognises it throughout the IR pipeline and codegen erases the marker back to a plain `fn()`, the same treatment magic-do's own effect runs get.\n\nWith both in place, `mkFn3` lifts to `\\fn -> AbsN [a, b, c] (fn(a)(b)(c))`, and a `mkFn3 \\a b c -> …` site beta-reduces layer by layer to a bare n-ary `AbsN`, i.e. a direct Lua `function(a, b, c)` definition. Compositions with the run half reduce end to end: `runFn3 (mkFn3 f) x y z` collapses to `f x y z`, and `mkEffectFn2 (runEffectFn2 h)` either reduces to a direct `AppN h [a, b]` (the marker lands on the thunk's unused parameter and is dropped) or is left as the effect-run redex that the codegen fusion from #226 already collapses.\n\nOne guardrail belongs in the allowlist comment: after this change the Effect core (`bindE`, `pureE`) becomes technically liftable (their bodies are pure return trees), but it must not be allowlisted. Magic-do recognises bind chains by name, and inline-always lifting of `bindE` in the optimizer fixpoint (which runs before magic-do) would blind that recognition, which would cost the flat do-chunks and with them the handling of Lua's nesting and locals limits (#19). The broader-allowlist follow-up (#187) needs that warning spelled out.\n\n## Future direction (#228)\n\nThe cleaner endgame is marker-driven magic-do: normalise every effect run to `EffectRunArg` before magic-do runs, and build do-chunks from those semantics instead of recognising `bindE`/`pureE` by name. That would remove the name-driven fragility the guardrail above works around, but it means redesigning magic-do's recognition and the way chunk boundaries keep generated functions within Lua's limits (#19), so it is tracked separately in #228.\n","author":{"url":"https://github.com/Unisay","@type":"Person","name":"Unisay"},"datePublished":"2026-07-11T09:27:58Z","url":"https://github.com/purescript-lua/purescript-lua/issues/227"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:bf18aa35-1117-0d96-da85-bfbe36f917c3
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id909E:2454CC:723820:92FFAB:6B00E452
html-safe-nonce14aef28f22cd80d000f585acf19331c2cad58b17afb8fce5875f334b787b947f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDlFOjI0NTRDQzo3MjM4MjA6OTJGRkFCOjZCMDBFNDUyIiwidmlzaXRvcl9pZCI6Ijg3Njk3MzIxMjk2NDgwNzU4NTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac77c6bffc41f04d78223bc7622710f8d0f62c8c895ab6bf2bfdb707c0befff9f5
hovercard-subject-tagissue:4861604645
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/purescript-lua/purescript-lua/227/issue_layout
twitter:imagehttps://opengraph.githubassets.com/ff7aaf20b8d5cfaf421e990b074c4d5da9391578d0e00204fd1069f344289ce5/purescript-lua/purescript-lua/issues/227
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/ff7aaf20b8d5cfaf421e990b074c4d5da9391578d0e00204fd1069f344289ce5/purescript-lua/purescript-lua/issues/227
og:image:alt#226 (issue #198) lifted the run half of the uncurried wrappers: a saturated runFn3 add3 1 2 3 now compiles to add3(1, 2, 3). The constructors stayed opaque FFI, and they undo much of the win. add3...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameUnisay
hostnamegithub.com
expected-hostnamegithub.com
None27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14
turbo-cache-controlno-preview
go-importgithub.com/purescript-lua/purescript-lua git https://github.com/purescript-lua/purescript-lua.git
octolytics-dimension-user_id131581790
octolytics-dimension-user_loginpurescript-lua
octolytics-dimension-repository_id587200487
octolytics-dimension-repository_nwopurescript-lua/purescript-lua
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id587200487
octolytics-dimension-repository_network_root_nwopurescript-lua/purescript-lua
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release624179fb8b88d26ba5bba08894eb60a1c5a1d93d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/purescript-lua/purescript-lua/issues/227#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpurescript-lua%2Fpurescript-lua%2Fissues%2F227
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpurescript-lua%2Fpurescript-lua%2Fissues%2F227
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=purescript-lua%2Fpurescript-lua
Reloadhttps://github.com/purescript-lua/purescript-lua/issues/227
Reloadhttps://github.com/purescript-lua/purescript-lua/issues/227
Reloadhttps://github.com/purescript-lua/purescript-lua/issues/227
purescript-luahttps://github.com/purescript-lua
purescript-luahttps://github.com/purescript-lua/purescript-lua
Codehttps://github.com/purescript-lua/purescript-lua
Issues48 (48)https://github.com/purescript-lua/purescript-lua/issues
Pull requestshttps://github.com/purescript-lua/purescript-lua/pulls
Discussionshttps://github.com/purescript-lua/purescript-lua/discussions
Actionshttps://github.com/purescript-lua/purescript-lua/actions
Projectshttps://github.com/purescript-lua/purescript-lua/projects
Security and qualityhttps://github.com/purescript-lua/purescript-lua/security
Insightshttps://github.com/purescript-lua/purescript-lua/insights
https://github.com/purescript-lua/purescript-lua
New issuehttps://github.com/login?return_to=https://github.com/purescript-lua/purescript-lua/issues/227
New issuehttps://github.com/login?return_to=https://github.com/purescript-lua/purescript-lua/issues/227
#229https://github.com/purescript-lua/purescript-lua/pull/229
Lift the *.Uncurried mk wrappers to n-ary function definitionshttps://github.com/purescript-lua/purescript-lua/issues/227#top
#229https://github.com/purescript-lua/purescript-lua/pull/229
OptimisationA Compiler Optimisationhttps://github.com/purescript-lua/purescript-lua/issues?q=state%3Aopen%20label%3A%22Optimisation%22
area: irIR / optimizer / DCE / inlinerhttps://github.com/purescript-lua/purescript-lua/issues?q=state%3Aopen%20label%3A%22area%3A%20ir%22
enhancementNew feature or requesthttps://github.com/purescript-lua/purescript-lua/issues?q=state%3Aopen%20label%3A%22enhancement%22
https://github.com/Unisay
Unisayhttps://github.com/Unisay
on Jul 11, 2026https://github.com/purescript-lua/purescript-lua/issues/227#issue-4861604645
#226https://github.com/purescript-lua/purescript-lua/pull/226
#198https://github.com/purescript-lua/purescript-lua/issues/198
#226https://github.com/purescript-lua/purescript-lua/pull/226
#178https://github.com/purescript-lua/purescript-lua/issues/178
#198https://github.com/purescript-lua/purescript-lua/issues/198
Program transformation to uncurry functions for which all applications are fully saturated. #24https://github.com/purescript-lua/purescript-lua/issues/24
#226https://github.com/purescript-lua/purescript-lua/pull/226
#19https://github.com/purescript-lua/purescript-lua/issues/19
#187https://github.com/purescript-lua/purescript-lua/issues/187
#228https://github.com/purescript-lua/purescript-lua/issues/228
#19https://github.com/purescript-lua/purescript-lua/issues/19
#228https://github.com/purescript-lua/purescript-lua/issues/228
Unisayhttps://github.com/Unisay
on Jul 11, 2026https://github.com/purescript-lua/purescript-lua/issues/227#event-27848559050
docs: retarget the mk-wrapper references from #24 to #227https://github.com/purescript-lua/purescript-lua/commit/fbf1cdca025b8a92b1a26bea9af553effd2ccf81
#24https://github.com/purescript-lua/purescript-lua/issues/24
#227https://github.com/purescript-lua/purescript-lua/issues/227
fbf1cdchttps://github.com/purescript-lua/purescript-lua/commit/fbf1cdca025b8a92b1a26bea9af553effd2ccf81
Unisayhttps://github.com/Unisay
enhancementNew feature or requesthttps://github.com/purescript-lua/purescript-lua/issues?q=state%3Aopen%20label%3A%22enhancement%22
area: irIR / optimizer / DCE / inlinerhttps://github.com/purescript-lua/purescript-lua/issues?q=state%3Aopen%20label%3A%22area%3A%20ir%22
OptimisationA Compiler Optimisationhttps://github.com/purescript-lua/purescript-lua/issues?q=state%3Aopen%20label%3A%22Optimisation%22
on Jul 11, 2026https://github.com/purescript-lua/purescript-lua/issues/227#event-27849913241
Unisayhttps://github.com/Unisay
on Jul 11, 2026https://github.com/purescript-lua/purescript-lua/issues/227#event-27850290155
Merge pull request #229 from purescript-lua/issue-227/lift-uncurried-…https://github.com/purescript-lua/purescript-lua/commit/72f88a59c9b8ebcffc971fb45fb8f2a093fd1804
#229https://github.com/purescript-lua/purescript-lua/pull/229
72f88a5https://github.com/purescript-lua/purescript-lua/commit/72f88a59c9b8ebcffc971fb45fb8f2a093fd1804
Unisayhttps://github.com/Unisay
completedhttps://github.com/purescript-lua/purescript-lua/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#229https://github.com/purescript-lua/purescript-lua/pull/229
on Jul 11, 2026https://github.com/purescript-lua/purescript-lua/issues/227#event-27850290182
Sign up for freehttps://github.com/signup?return_to=https://github.com/purescript-lua/purescript-lua/issues/227
Sign in to commenthttps://github.com/login?return_to=https://github.com/purescript-lua/purescript-lua/issues/227
OptimisationA Compiler Optimisationhttps://github.com/purescript-lua/purescript-lua/issues?q=state%3Aopen%20label%3A%22Optimisation%22
area: irIR / optimizer / DCE / inlinerhttps://github.com/purescript-lua/purescript-lua/issues?q=state%3Aopen%20label%3A%22area%3A%20ir%22
enhancementNew feature or requesthttps://github.com/purescript-lua/purescript-lua/issues?q=state%3Aopen%20label%3A%22enhancement%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.