René's URL Explorer Experiment


Title: Lift the *.Uncurried mk wrappers to n-ary function definitions (#227) by Unisay · Pull Request #229 · purescript-lua/purescript-lua · GitHub

Open Graph Title: Lift the *.Uncurried mk wrappers to n-ary function definitions (#227) by Unisay · Pull Request #229 · purescript-lua/purescript-lua

X Title: Lift the *.Uncurried mk wrappers to n-ary function definitions (#227) by Unisay · Pull Request #229 · purescript-lua/purescript-lua

Description: Closes #227. #226 lifted the run half of the uncurried wrappers: a saturated runFn3 add3 1 2 3 compiles to add3(1, 2, 3). The constructors stayed opaque FFI, though, and they undid much of the win. add3 = mkFn3 \a b c -> a + b + c still emitted as mkFn3(function(a) return function(b) return function(c) … end end end), uncurried on the outside but re-curried on the inside via fn(a)(b)(c), so every call of a Fn3 built this way allocated two intermediate closures. This PR lifts the mk half. The definition now compiles to function(a, b, c) return a + b + c end with no closures at all, and the mk* accessors disappear from the emitted FFI tables the same way the run* ones did in #226. Changes 1. Lift the mk wrappers (ForeignLift). Two shapes join the translatable subset. A multi-parameter function literal lifts to a single n-ary AbsN, provided every parameter is named and the names are pairwise distinct: a vararg declines, and so does a duplicate name, because Lua binds the body's reference to the last same-named parameter and an AbsN would silently miscompile it. A nullary call fn() (the trailing effect run of the mk{ST,Effect}FnN wrappers) lifts to an application of the EffectRunArg marker, the same shape magic-do emits; codegen erases it back to an empty argument list. The literal-head arity guard from #226 stays exact, with the marker counting as one argument, so a thunk head passes and any wider literal declines. mkFn2…mkFn10, mkSTFn1…mkSTFn10, and mkEffectFn1…mkEffectFn10 join the allowlist. runFn0/mkFn0 stay off it by policy, not liftability: their bodies force a pure Fn0 with a nullary call, which must not be marked an effect run. 2. Guard the allowlist against lifting the Effect/ST core. With nullary calls translatable, the core (Effect.bindE/pureE, Control.Monad.ST.Internal.bind_/pure_) becomes technically liftable, and the allowlist Haddock now warns the broader-allowlist follow-up (#187) off it. Magic-do recognises bind chains by name, so an inline-always core would be inlined away during the optimizer fixpoint, which runs before magic-do, and that recognition would go blind: no flat do-chunks, and none of the chunked statement sequences that keep the output under Lua's local-variable limits (#19). Lifting the core behind a marker magic-do understands is tracked in #228. Before / after Pure definitions collapse to n-ary literals, including the point-free mulByFn = mkFn2 mul, whose wrapped function arrives through dictionary resolution rather than as a literal lambda: -- before: M.Golden_UncurriedLift_Test_add3 = M.Data_Function_Uncurried_foreign.mkFn3(function( a ) return function(b) return function(c) return a + b + c end end end) -- after: M.Golden_UncurriedLift_Test_add3 = function(a, b, c) return a + b + c end M.Golden_UncurriedLift_Test_mulByFn = function(a, b) return a * b end An effectful body whose thunk head is not a literal erases the marker into a direct force: M.Golden_UncurriedLift_Test_sumST = function(a, b) return M.Control_Monad_ST_Internal_applicativeST.pure(a + b)() end One shape keeps a residual closure. A do-block body (logTwice = mkEffectFn2 \a b -> do …) is a statement sequence, and the codegen thunk fusion from #226 only covers single-call bodies, so the run of the magic-do chunk emits as an IIFE inside the n-ary literal: one closure per call, down from the wrapper's two. A tail-position IIFE collapse in the Lua optimizer would finish the job; #230 tracks that as optimizer work independent of the lifter. The Data.Function.Uncurried, Effect.Uncurried, and Control.Monad.ST.Uncurried foreign tables are gone from the golden output entirely. Verification The lifter specs were written first and red: five new positive shapes (mkFn2, mkEffectFn2, mkSTFn1, a bare multi-parameter literal, a nullary call) plus new declines (a vararg, duplicate parameter names, an under-applied multi-parameter head). The UncurriedLift golden gains the mulByFn case, with its hand-written eval oracle line (48) added before any run; the checked golden pipeline lints scoping, uniqueness, and well-appliedness at every pass boundary. Full cabal test all is green (718 examples), the spec suite was repeated on three fresh Hedgehog seeds, luacheck reports no errors, and the bench FNEW census is unchanged (the bench modules use no mk* wrappers).

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

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

Opengraph URL: https://github.com/purescript-lua/purescript-lua/pull/229

X: @github

direct link

Domain: github.com

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/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:8b2e9f23-0460-3c8d-f128-623dfbd257df
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idBD30:6FAD8:C9F4FB:104C608:6B00EF99
html-safe-nonce9ed2a0d880cb51c9bfadb1bfa017ee5fd6e963f58f41769d1718deadb676c874
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDMwOjZGQUQ4OkM5RjRGQjoxMDRDNjA4OjZCMDBFRjk5IiwidmlzaXRvcl9pZCI6Ijc2MTU4MDk4MTYwNTY4ODUxNDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacaf2df7c23a22d68f416419ce207652b48902b8abed27b50ce5daca94690371ac
hovercard-subject-tagpull_request:4035093211
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/purescript-lua/purescript-lua/pull/229/files
twitter:imagehttps://avatars.githubusercontent.com/u/1009751?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/1009751?s=400&v=4
og:image:altCloses #227. #226 lifted the run half of the uncurried wrappers: a saturated runFn3 add3 1 2 3 compiles to add3(1, 2, 3). The constructors stayed opaque FFI, though, and they undid much of the win....
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc
turbo-cache-controlno-preview
diff-viewunified
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 full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release9983dd5da06943f833c971dd5b6bc988e2858be5
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/purescript-lua/purescript-lua/pull/229/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpurescript-lua%2Fpurescript-lua%2Fpull%2F229%2Ffiles
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%2Fpull%2F229%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=purescript-lua%2Fpurescript-lua
Reloadhttps://github.com/purescript-lua/purescript-lua/pull/229/files
Reloadhttps://github.com/purescript-lua/purescript-lua/pull/229/files
Reloadhttps://github.com/purescript-lua/purescript-lua/pull/229/files
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
Sign up for GitHub https://github.com/signup?return_to=%2Fpurescript-lua%2Fpurescript-lua%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpurescript-lua%2Fpurescript-lua%2Fissues%2Fnew%2Fchoose
Unisayhttps://github.com/Unisay
mainhttps://github.com/purescript-lua/purescript-lua/tree/main
issue-227/lift-uncurried-mk-wrappershttps://github.com/purescript-lua/purescript-lua/tree/issue-227/lift-uncurried-mk-wrappers
Conversation 1 https://github.com/purescript-lua/purescript-lua/pull/229
Commits 2 https://github.com/purescript-lua/purescript-lua/pull/229/commits
Checks 2 https://github.com/purescript-lua/purescript-lua/pull/229/checks
Files changed https://github.com/purescript-lua/purescript-lua/pull/229/files
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/229/files
Lift the *.Uncurried mk wrappers to n-ary function definitions (#227) https://github.com/purescript-lua/purescript-lua/pull/229/files#top
Show all changes 2 commits https://github.com/purescript-lua/purescript-lua/pull/229/files
8425781 feat(foreign-lift): lift the *.Uncurried mk wrappers to n-ary definit… Unisay Jul 11, 2026 https://github.com/purescript-lua/purescript-lua/pull/229/commits/842578168c7d5422b716be18b59d703b0a539059
b8b61d7 test(golden): exercise the mk half of UncurriedLift through the lifte… Unisay Jul 11, 2026 https://github.com/purescript-lua/purescript-lua/pull/229/commits/b8b61d7705a9cdc2ff7a9037a7f2e0b0e7fc5051
Clear filters https://github.com/purescript-lua/purescript-lua/pull/229/files
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/229/files
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/229/files
20260711_123511_unisay_lift_uncurried_mk_wrappers.md https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-1b1d613ef30d64c5a1213331a37f47445ef8b6386ac9e2868e7743eeef5376aa
ForeignLift.hs https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-04993d8007dd16f4e9ba39db94723d139ffaa8f44c2c3357cf86e2c62dfd6410
Spec.hs https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-4e88bcf71461d23965f558682bc7ec0518a9602484c5157516c7c40645df8654
corefn.json https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-cd420b327ffcb93b039cba963e0992bc29c8453f587fdb64b4d63d8b1497c546
golden.txt https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-dba231e22a516bb3f3fed3f758476f24e58818d717d217ec090a2323efba2ccf
golden.ir https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-9f1799ede16b2de76bbd9ce943935d297b0b2196125598eee26cc4313177c6b4
golden.lua https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-5921e666a0348af0dd78380b07fead46422cafb2d7dadb38988ae54c01af9164
Test.purs https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-da1fff8019643b3506a7049c6e6ad30eeb20756bc1e9b478a8ba87ba2eaf22a4
changelog.d/20260711_123511_unisay_lift_uncurried_mk_wrappers.mdhttps://github.com/purescript-lua/purescript-lua/pull/229/files#diff-1b1d613ef30d64c5a1213331a37f47445ef8b6386ac9e2868e7743eeef5376aa
View file https://github.com/purescript-lua/purescript-lua/blob/b8b61d7705a9cdc2ff7a9037a7f2e0b0e7fc5051/changelog.d/20260711_123511_unisay_lift_uncurried_mk_wrappers.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/229/{{ revealButtonHref }}
lib/Language/PureScript/Backend/Lua/ForeignLift.hshttps://github.com/purescript-lua/purescript-lua/pull/229/files#diff-04993d8007dd16f4e9ba39db94723d139ffaa8f44c2c3357cf86e2c62dfd6410
View file https://github.com/purescript-lua/purescript-lua/blob/b8b61d7705a9cdc2ff7a9037a7f2e0b0e7fc5051/lib/Language/PureScript/Backend/Lua/ForeignLift.hs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/229/{{ revealButtonHref }}
https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-04993d8007dd16f4e9ba39db94723d139ffaa8f44c2c3357cf86e2c62dfd6410
https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-04993d8007dd16f4e9ba39db94723d139ffaa8f44c2c3357cf86e2c62dfd6410
https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-04993d8007dd16f4e9ba39db94723d139ffaa8f44c2c3357cf86e2c62dfd6410
https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-04993d8007dd16f4e9ba39db94723d139ffaa8f44c2c3357cf86e2c62dfd6410
https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-04993d8007dd16f4e9ba39db94723d139ffaa8f44c2c3357cf86e2c62dfd6410
https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-04993d8007dd16f4e9ba39db94723d139ffaa8f44c2c3357cf86e2c62dfd6410
https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-04993d8007dd16f4e9ba39db94723d139ffaa8f44c2c3357cf86e2c62dfd6410
https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-04993d8007dd16f4e9ba39db94723d139ffaa8f44c2c3357cf86e2c62dfd6410
https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-04993d8007dd16f4e9ba39db94723d139ffaa8f44c2c3357cf86e2c62dfd6410
https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-04993d8007dd16f4e9ba39db94723d139ffaa8f44c2c3357cf86e2c62dfd6410
test/Language/PureScript/Backend/Lua/ForeignLift/Spec.hshttps://github.com/purescript-lua/purescript-lua/pull/229/files#diff-4e88bcf71461d23965f558682bc7ec0518a9602484c5157516c7c40645df8654
View file https://github.com/purescript-lua/purescript-lua/blob/b8b61d7705a9cdc2ff7a9037a7f2e0b0e7fc5051/test/Language/PureScript/Backend/Lua/ForeignLift/Spec.hs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/229/{{ revealButtonHref }}
https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-4e88bcf71461d23965f558682bc7ec0518a9602484c5157516c7c40645df8654
https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-4e88bcf71461d23965f558682bc7ec0518a9602484c5157516c7c40645df8654
https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-4e88bcf71461d23965f558682bc7ec0518a9602484c5157516c7c40645df8654
https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-4e88bcf71461d23965f558682bc7ec0518a9602484c5157516c7c40645df8654
https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-4e88bcf71461d23965f558682bc7ec0518a9602484c5157516c7c40645df8654
https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-4e88bcf71461d23965f558682bc7ec0518a9602484c5157516c7c40645df8654
https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-4e88bcf71461d23965f558682bc7ec0518a9602484c5157516c7c40645df8654
test/ps/output/Golden.UncurriedLift.Test/corefn.jsonhttps://github.com/purescript-lua/purescript-lua/pull/229/files#diff-cd420b327ffcb93b039cba963e0992bc29c8453f587fdb64b4d63d8b1497c546
View file https://github.com/purescript-lua/purescript-lua/blob/b8b61d7705a9cdc2ff7a9037a7f2e0b0e7fc5051/test/ps/output/Golden.UncurriedLift.Test/corefn.json
Open in desktop https://desktop.github.com
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/229/files
test/ps/output/Golden.UncurriedLift.Test/eval/golden.txthttps://github.com/purescript-lua/purescript-lua/pull/229/files#diff-dba231e22a516bb3f3fed3f758476f24e58818d717d217ec090a2323efba2ccf
View file https://github.com/purescript-lua/purescript-lua/blob/b8b61d7705a9cdc2ff7a9037a7f2e0b0e7fc5051/test/ps/output/Golden.UncurriedLift.Test/eval/golden.txt
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/229/{{ revealButtonHref }}
https://github.com/purescript-lua/purescript-lua/pull/229/files#diff-dba231e22a516bb3f3fed3f758476f24e58818d717d217ec090a2323efba2ccf
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/229/files
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.