René's URL Explorer Experiment


Title: feat(ir): uncurry the shapes that only appear after magicDo and flattening by Unisay · Pull Request #264 · purescript-lua/purescript-lua · GitHub

Open Graph Title: feat(ir): uncurry the shapes that only appear after magicDo and flattening by Unisay · Pull Request #264 · purescript-lua/purescript-lua

X Title: feat(ir): uncurry the shapes that only appear after magicDo and flattening by Unisay · Pull Request #264 · purescript-lua/purescript-lua

Description: Closes #200. The worker/wrapper uncurrying pass (#24) now runs a second time at the end of the IR pipeline, after flattenDeepBinds, followed by a single dce pass. The late run catches the saturated call sites that do not exist at the early run's position: the effect-run spines magicDo completes, and the $kont helpers minted by flattening. The helpers are saturated by construction, so their curried kontN(live)(x) calls become kontN$w(live, x) and the wrappers die in the closing dce pass. One correction to the issue's premise surfaced while updating goldens. An effect function with two or more real arguments is already split by the early run, because its real-argument spine is saturated before magicDo runs: bindE (f a b) k contains the full f(a)(b). For those functions the late run adds nothing; the thunk stays inside the early worker, and absorbing it there is a possible follow-up. The family the late run actually wins is the unary effect action. f :: A -> Effect B has manifest arity 1, below the split threshold, until magicDo appends the thunk parameter, and the late split absorbs that parameter into the worker: a fully applied effect statement compiles to the single call f$w(a) instead of f(a)() with a thunk allocated per call. The new Golden/UncurryEffect test covers this end to end, with an eval oracle for semantics. Three pieces of groundwork make the rerun sound: isEffectRun now recognises an effect run by its trailing EffectRunArg instead of only the singleton application. Without this, rewriting f(a)(b)(run) to f$w(a, b, run) would strip the statement's protections and dead code elimination would silently drop the effect. New DCE and inliner tests cover the protections; the Lua codegen already erased trailing markers from n-ary argument lists. The pass is now rerun-safe. A wrapper built by the earlier run (recognised by its delegate-call body) is never split again, since that would mint a duplicate $w binding. It re-registers its arity instead, so saturated sites that appeared between the runs still reach the existing worker. A non-wrapper candidate whose $w name is taken is left alone entirely. The cleanup after the late run is a lone dce pass, not the optimize+dce fixpoint the issue sketched. Optimize's use-once inlining would paste the $kont workers (each called exactly once) back into their call sites one fixpoint round at a time, re-nesting exactly what flattenDeepBinds had just flattened and tripping Lua's parser nesting cap again. Golden churn is confined to the four Long*Bind modules (the $kont split) plus the new test, and every eval oracle passes unchanged. The full suite is green (899 examples) and the randomized specs hold across five extra seeds. The new bench/macro/effect_step bench records the improved shape and commits baseline counters. Wall-clock on that micro is flat: the step body's ST-ref FFI calls are still curried and dominate the saved call and thunk allocation, which is itself an argument for the follow-ups below. Two follow-up candidates came out of this work and stayed out of scope: absorbing the thunk parameter into workers the early run already split (the logShow$w(x, true)() shape visible in the Primops golden), and distributing an effect-run application into IfThenElse branches, which an if-terminated effect loop still needs before loopification (#181) can turn it into a while loop.

Open Graph Description: Closes #200. The worker/wrapper uncurrying pass (#24) now runs a second time at the end of the IR pipeline, after flattenDeepBinds, followed by a single dce pass. The late run catches the saturated...

X Description: Closes #200. The worker/wrapper uncurrying pass (#24) now runs a second time at the end of the IR pipeline, after flattenDeepBinds, followed by a single dce pass. The late run catches the saturated...

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

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:f9ee4dd2-2d98-6943-5ee6-c6c7eb17b663
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA65C:317608:782320:99EB06:6B00E484
html-safe-nonce0a2ae865cec9115d17d5d24146cd95fce196c8cf192f890e2b9027f2334e91c2
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjVDOjMxNzYwODo3ODIzMjA6OTlFQjA2OjZCMDBFNDg0IiwidmlzaXRvcl9pZCI6IjM1ODM1MTEwNjMzMzkwMDA5NjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacd96cf80eb1464fa2023f3cad4801f9567a3351201d2079534e554568b19f0924
hovercard-subject-tagpull_request:4044924062
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/264/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 #200. The worker/wrapper uncurrying pass (#24) now runs a second time at the end of the IR pipeline, after flattenDeepBinds, followed by a single dce pass. The late run catches the saturated...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14
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
release624179fb8b88d26ba5bba08894eb60a1c5a1d93d
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/purescript-lua/purescript-lua/pull/264/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpurescript-lua%2Fpurescript-lua%2Fpull%2F264%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%2F264%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/264/files
Reloadhttps://github.com/purescript-lua/purescript-lua/pull/264/files
Reloadhttps://github.com/purescript-lua/purescript-lua/pull/264/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-200/late-uncurry-rerunhttps://github.com/purescript-lua/purescript-lua/tree/issue-200/late-uncurry-rerun
Conversation 5 https://github.com/purescript-lua/purescript-lua/pull/264
Commits 5 https://github.com/purescript-lua/purescript-lua/pull/264/commits
Checks 2 https://github.com/purescript-lua/purescript-lua/pull/264/checks
Files changed https://github.com/purescript-lua/purescript-lua/pull/264/files
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/264/files
feat(ir): uncurry the shapes that only appear after magicDo and flattening https://github.com/purescript-lua/purescript-lua/pull/264/files#top
Show all changes 5 commits https://github.com/purescript-lua/purescript-lua/pull/264/files
4228787 feat(ir): recognise n-ary effect runs by the trailing marker Unisay Jul 13, 2026 https://github.com/purescript-lua/purescript-lua/pull/264/commits/4228787bb1530b0b23336ce7e5adc492973287a7
b95b425 feat(ir): make the uncurry pass rerun-safe Unisay Jul 13, 2026 https://github.com/purescript-lua/purescript-lua/pull/264/commits/b95b425816f271ca1d85d5b296f0368d4bb24f82
d23ceea feat(ir): rerun uncurry after flattenDeepBinds Unisay Jul 13, 2026 https://github.com/purescript-lua/purescript-lua/pull/264/commits/d23ceeae26835be7e9c88b51f1d94237ffb6082b
255a428 bench(macro): add effect_step, the late-uncurry shape Unisay Jul 13, 2026 https://github.com/purescript-lua/purescript-lua/pull/264/commits/255a4286fc130da1d7566b88b1e9bf5d5b69bd5e
0fa419e address copilot review on PR #264 Unisay Jul 13, 2026 https://github.com/purescript-lua/purescript-lua/pull/264/commits/0fa419e8cc0f176798c82dbe11c7be9853963fee
Clear filters https://github.com/purescript-lua/purescript-lua/pull/264/files
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/264/files
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/264/files
fnew_Bench.EffectStep.txt https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-d142955d9df01a6142e53c498a86ac3e67dee7806b0eb7268fac26fa7d3a33f6
trace_effect_step.txt https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-7904b97af15917900da64d4eced661d2fe5064da227bec607e8f39eccdf80f49
effect_step.lua https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-e906938a5104fc939223fa0d17c0d4ffc8dd099a6664ecaca53465a480916293
20260713_160000_unisay_late_uncurry_rerun.md https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-3013854f59098fb161246725d6ced66925e088251fc24d92b8a0d3c1aade61b6
Optimizer.hs https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-487ead9d0ca9c3e6f68e23c604b0ae9070089e0dd0f7d214cdce5fbc878f3315
Types.hs https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-c628fb950daac01f47dc80a039e24b8b452f9d578ab0d55483d10758027b4884
Uncurry.hs https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-d8f0f9deba1b4901c6f40711b679be7148c1b038a1cda1c7b0fdd7ca4f984043
Spec.hs https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-65198fee01b184497bda5bc384f6f9ca56ea758b20a66b44e6017bb5f832ef2d
Spec.hs https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-241ea2421c606c31b9414fb386f9f4d1beb60055ed792935b393101edfd7b949
Spec.hs https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-27b9dbdc5e29537b001047533fe16af650ee77df21724c529030f0e22fe00f41
golden.ir https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-cbb1b972839736658601bbee6059e002ea2a36bbeed1f407d41f597f6e2e453e
golden.lua https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-f943719d3e54c980d05ce8d70c52e063d34f21edfe9181c6eb2163757d0c686a
golden.ir https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-b3d35ac4539244a4144b23d703c439de0dc3c45b642f70979c085d8988537395
golden.lua https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-de9cc01bca01b7d30657c206f503b086d5a34c7c214e6db6ea028b7f2c5c9136
golden.ir https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-7a5e6ec2b228f8dd1754d9be1c4bc7b8a7a7da9664cfe3d699b951ef7571a65d
golden.lua https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-5d1488308753286a8e625bdfe9990357d9d69446fcca6f62f5e5fa24806b1c5b
golden.ir https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-8be75600b729c24bd7e6da1875279fbeaf3c2cd9940eda1c1882b1f58b8269ad
golden.lua https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-eb900aa47a3a6fb8d5a7e6e38095800ee1d6e13997f9b8b2354bdcdebed12e65
corefn.json https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-e7829939752af417595b5715e9f4a8a889538c975acb1bbfd410d7526e3f6b31
.gitignore https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-2472e36840fddec5f857576d6412a93eac734f214a371ce53b90c009f18b822e
golden.txt https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-5173cc8d6c19fe20060e704f5ea57c1fe752979638d187151b0cc5909763f7d1
golden.ir https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-afce6b8baac1ba8767363e541803baa37fca9f4bbabbf612d91769ec36efc412
golden.lua https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-ac5bf4ca9d458346d8eadd0865c78e8f31b6e180153f1aee53f9874d2313eb8e
EffectStep.purs https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-554da5a92f67d2ea843bcc0508ad231dc6c69905cbec318ee255159e0e9e47dd
Test.purs https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-e84a35a941b9102d87cffe51535572084d4a205be8be9ae1c2cafc274b6c254b
bench/goldens/fnew_Bench.EffectStep.txthttps://github.com/purescript-lua/purescript-lua/pull/264/files#diff-d142955d9df01a6142e53c498a86ac3e67dee7806b0eb7268fac26fa7d3a33f6
View file https://github.com/purescript-lua/purescript-lua/blob/0fa419e8cc0f176798c82dbe11c7be9853963fee/bench/goldens/fnew_Bench.EffectStep.txt
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/264/{{ revealButtonHref }}
bench/goldens/trace_effect_step.txthttps://github.com/purescript-lua/purescript-lua/pull/264/files#diff-7904b97af15917900da64d4eced661d2fe5064da227bec607e8f39eccdf80f49
View file https://github.com/purescript-lua/purescript-lua/blob/0fa419e8cc0f176798c82dbe11c7be9853963fee/bench/goldens/trace_effect_step.txt
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/264/{{ revealButtonHref }}
bench/macro/effect_step.luahttps://github.com/purescript-lua/purescript-lua/pull/264/files#diff-e906938a5104fc939223fa0d17c0d4ffc8dd099a6664ecaca53465a480916293
View file https://github.com/purescript-lua/purescript-lua/blob/0fa419e8cc0f176798c82dbe11c7be9853963fee/bench/macro/effect_step.lua
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/264/{{ revealButtonHref }}
changelog.d/20260713_160000_unisay_late_uncurry_rerun.mdhttps://github.com/purescript-lua/purescript-lua/pull/264/files#diff-3013854f59098fb161246725d6ced66925e088251fc24d92b8a0d3c1aade61b6
View file https://github.com/purescript-lua/purescript-lua/blob/0fa419e8cc0f176798c82dbe11c7be9853963fee/changelog.d/20260713_160000_unisay_late_uncurry_rerun.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/264/{{ revealButtonHref }}
lib/Language/PureScript/Backend/IR/Optimizer.hshttps://github.com/purescript-lua/purescript-lua/pull/264/files#diff-487ead9d0ca9c3e6f68e23c604b0ae9070089e0dd0f7d214cdce5fbc878f3315
View file https://github.com/purescript-lua/purescript-lua/blob/0fa419e8cc0f176798c82dbe11c7be9853963fee/lib/Language/PureScript/Backend/IR/Optimizer.hs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/264/{{ revealButtonHref }}
https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-487ead9d0ca9c3e6f68e23c604b0ae9070089e0dd0f7d214cdce5fbc878f3315
https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-487ead9d0ca9c3e6f68e23c604b0ae9070089e0dd0f7d214cdce5fbc878f3315
https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-487ead9d0ca9c3e6f68e23c604b0ae9070089e0dd0f7d214cdce5fbc878f3315
https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-487ead9d0ca9c3e6f68e23c604b0ae9070089e0dd0f7d214cdce5fbc878f3315
https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-487ead9d0ca9c3e6f68e23c604b0ae9070089e0dd0f7d214cdce5fbc878f3315
https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-487ead9d0ca9c3e6f68e23c604b0ae9070089e0dd0f7d214cdce5fbc878f3315
lib/Language/PureScript/Backend/IR/Types.hshttps://github.com/purescript-lua/purescript-lua/pull/264/files#diff-c628fb950daac01f47dc80a039e24b8b452f9d578ab0d55483d10758027b4884
View file https://github.com/purescript-lua/purescript-lua/blob/0fa419e8cc0f176798c82dbe11c7be9853963fee/lib/Language/PureScript/Backend/IR/Types.hs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/264/{{ revealButtonHref }}
https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-c628fb950daac01f47dc80a039e24b8b452f9d578ab0d55483d10758027b4884
https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-c628fb950daac01f47dc80a039e24b8b452f9d578ab0d55483d10758027b4884
https://github.com/purescript-lua/purescript-lua/pull/264/files#diff-c628fb950daac01f47dc80a039e24b8b452f9d578ab0d55483d10758027b4884
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/264/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.