René's URL Explorer Experiment


Title: feat(optimizer): splice a tail-position application of a function literal by Unisay · Pull Request #296 · purescript-lua/purescript-lua · GitHub

Open Graph Title: feat(optimizer): splice a tail-position application of a function literal by Unisay · Pull Request #296 · purescript-lua/purescript-lua

X Title: feat(optimizer): splice a tail-position application of a function literal by Unisay · Pull Request #296 · purescript-lua/purescript-lua

Description: Closes #295. What Generalizes the tail-position IIFE collapse (#230) to an applied function literal with named parameters, and renames the rule accordingly: collapseTailScopeCall → collapseTailLiteralApplication. When a function body ends in return (function(p1, …) end)(a1, …), the rule now binds the parameters as one simultaneous local and splices the body; the nullary shape degenerates to no binding statement, so #230's behaviour is the special case. On Golden.LongApplyChain.Test's applySecond — the shape PR #294 deliberately left behind, one closure allocation and one extra call per node of the 40-deep apply chain: return (function(v1_S_626) if "Data.Maybe∷Maybe.Just" == v_S_625[1] then ... end end)(b_S_134) becomes straight-line: local v1_S_626 = b_S_134 if "Data.Maybe∷Maybe.Just" == v_S_625[1] then ... end Why the local is exact The one-statement local p1, … = a1, … is the literal translation of Lua's call binding: the whole initializer list evaluates before any name binds (an argument reading an outer x can never see a parameter named x), a multi-valued expression last in the list expands, missing values fill with nil, and extra values evaluate and drop — the same adjustment rules the call performed. Unlike #294's fold, the arguments cross no scope boundary: the call site already was the parent's last statement, so they evaluate in the same environment at the same program point — which is also why ... among the arguments needs no check here. Conditions on top of #230's (vararg check on the spliced statements, the #19 local budget — now counting the parameter binding — and the self-re-application): every parameter is ParamNamed with no name repeating, and a nullary literal applied to arguments declines (no local binds zero names, and dropping the arguments would drop their effects). The second commit: re-collapse in expression position The first commit alone moved only 3 goldens; Golden.Issue37.Test and Golden.StringCodePoints.Test — both named in #295 — did not budge. The reason: their redexes sit in scope calls in expression position (a table row, an == operand), and the tail return (function(fn1) … end)(f) inside those scope calls is built by foldCallThroughScopeCall itself at a depth the bottom-up driver has already passed — the callee literal is visited before the enclosing call node, so nobody revisits the rebuilt literal. A literal in a function tail recovers when the driver reaches the enclosing function (collapseTailLiteralApplication fires there and re-applies); a literal in expression position had no later chance. The fold now hands each literal it rebuilds to collapseTailLiteralApplication directly — the same eager re-optimization foldFieldProjectionThroughScopeCall already does with its projected return, and the reason the fold now takes LuaLimits. In Golden.Issue37.Test: [1] = (function() local Bind1_S_216 = Effect_monadEffect.Bind1() return (function(fn1_S_218) return Bind1_S_216.bind(fn1_S_218)(function() ... end) end)(f_S_6) end)() becomes [1] = (function() local Bind1_S_216 = Effect_monadEffect.Bind1() local fn1_S_218 = f_S_6 return Bind1_S_216.bind(fn1_S_218)(function() ... end) end)() In Golden.LongWriterBind.Test the chain composes end-to-end — fold, collapse, projection fold, table-constructor fold — reducing ((function(dictApplicative_S_518) return { pure = …, Apply0 = … } end)(Data_Identity_applicativeIdentity)).pure(42) to local dictApplicative_S_518 = Data_Identity_applicativeIdentity local a_S_519 = 42 return dictApplicative_S_518.pure(Data_Tuple_Tuple_S_w(a_S_519, dictMonoid_S_517.mempty)) The folded-away Apply0 row held the only read of Control_Monad_Writer_Trans_applyWriterT_S_w (2 occurrences on main → 1 now: just the initializer), so promoteChunk correctly declines to promote a zero-read binding — that is why local M = {} reappears in this golden with the now-dead initializer parked as M.Control_Monad_Writer_Trans_applyWriterT_S_w = …. One golden also lost a nesting level that main's own output would have collapsed if re-fed to the optimizer (Golden.ArrayOfUnits.Test's main): the nesting was fold residue at a passed depth, the class this commit removes. Verification 20 unit tests for the rule pair, written red-first: the parameterized splice, nil-fill via local x, y = 1, the bare-rule re-collapse through a parameterized merge, declines (nullary-with-arguments, vararg/unused/duplicate parameters, budget counting the bound parameters), and the fold's re-collapse in expression position. One existing fold expectation updated: the nested-scope-call re-fold now flattens to a single scope call (strictly better output, same purpose). 7 golden.lua moved across the two commits (LongApplyChain, BugListGenericEq, ArrayOfUnits, Issue37, StringCodePoints, LongWriterBind); golden.ir untouched. All eval goldens byte-identical — the semantic oracle is never auto-accepted. bench/ci --accept produced no diffs: the bench modules carried none of the residual shapes after #294. cabal test all clean (1044 examples), fourmolu + hlint clean.

Open Graph Description: Closes #295. What Generalizes the tail-position IIFE collapse (#230) to an applied function literal with named parameters, and renames the rule accordingly: collapseTailScopeCall → collapseTailLite...

X Description: Closes #295. What Generalizes the tail-position IIFE collapse (#230) to an applied function literal with named parameters, and renames the rule accordingly: collapseTailScopeCall → collapseTailLite...

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

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:5c0d7317-21fa-3e27-9978-99a709e5fd43
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id834C:237673:BF739A:100F0F0:6B00F9C8
html-safe-noncef5ef052223f76329aac5cfab99a65d655fc22df5b27e9ce326d089fc1b6065f2
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MzRDOjIzNzY3MzpCRjczOUE6MTAwRjBGMDo2QjAwRjlDOCIsInZpc2l0b3JfaWQiOiI3NTk2OTE5NDkzMzI3MTI0OTM2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac78bd604ade907d49b7584851c858140e772b7abe359589d6a3c717271fd06b28
hovercard-subject-tagpull_request:4124488357
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/296/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 #295. What Generalizes the tail-position IIFE collapse (#230) to an applied function literal with named parameters, and renames the rule accordingly: collapseTailScopeCall → collapseTailLite...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonee208d86428ec00a57ade75058166297440e8128a01e5287c31a53dc042bbf187
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
release7dafd017fb7809a839c443dba08622af38e63c09
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/purescript-lua/purescript-lua/pull/296/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpurescript-lua%2Fpurescript-lua%2Fpull%2F296%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%2F296%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/296/files
Reloadhttps://github.com/purescript-lua/purescript-lua/pull/296/files
Reloadhttps://github.com/purescript-lua/purescript-lua/pull/296/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-295/splice-tail-literal-applicationhttps://github.com/purescript-lua/purescript-lua/tree/issue-295/splice-tail-literal-application
Conversation 0 https://github.com/purescript-lua/purescript-lua/pull/296
Commits 2 https://github.com/purescript-lua/purescript-lua/pull/296/commits
Checks 2 https://github.com/purescript-lua/purescript-lua/pull/296/checks
Files changed https://github.com/purescript-lua/purescript-lua/pull/296/files
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/296/files
feat(optimizer): splice a tail-position application of a function literal https://github.com/purescript-lua/purescript-lua/pull/296/files#top
Show all changes 2 commits https://github.com/purescript-lua/purescript-lua/pull/296/files
fb0b281 feat(optimizer): splice a tail-position application of a function lit… Unisay Jul 24, 2026 https://github.com/purescript-lua/purescript-lua/pull/296/commits/fb0b281e9c4e1826cb0dd8315009462a4c78e8f0
9ab5262 feat(optimizer): re-collapse the literal the trailing-call fold rebuilds Unisay Jul 24, 2026 https://github.com/purescript-lua/purescript-lua/pull/296/commits/9ab5262b3fb3c2d161e836fa3b81a5403636b1bb
Clear filters https://github.com/purescript-lua/purescript-lua/pull/296/files
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/296/files
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/296/files
20260724_150000_unisay_splice_tail_literal_application.md https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-b1c83ea60a1057f0a16dbc42426e0fab31b90d5dc403ae68c27def805eb4791e
Optimizer.hs https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-729235f45985a9f15089eee44d4ee219effa1f8365a3359452ff51c908fe5e41
Spec.hs https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-0cf3bacadac71b36286d45fe27adeb3db6839bc38502708722e8552067effd2a
golden.lua https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-d14061e081c835eadc7c359ed265bb765b321b458d478c3ba1cd2706ffc1b91f
golden.lua https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-0c90c2d7623d39f887ed98803e0198ce7532cb955c04690d5c518a02bb16d0e1
golden.lua https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-67e4dcf4711ce34fdb0ed8a2c23c4b638cf54c282818689a85be15ec720ace60
golden.lua https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-3058caa776257034fc5c6caf6cdcd1823934a0ed43d330ebdb6e26da662cf83e
golden.lua https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-7cb40758f0c4fe0117dcb551a917aaa5a04ec2c37fa895f3a24434fbda6f5d17
golden.lua https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-8f846c962c84e2efb0046e7848c15b3bac3e044be37a2d2ee0620f823f2e9b0f
changelog.d/20260724_150000_unisay_splice_tail_literal_application.mdhttps://github.com/purescript-lua/purescript-lua/pull/296/files#diff-b1c83ea60a1057f0a16dbc42426e0fab31b90d5dc403ae68c27def805eb4791e
View file https://github.com/purescript-lua/purescript-lua/blob/9ab5262b3fb3c2d161e836fa3b81a5403636b1bb/changelog.d/20260724_150000_unisay_splice_tail_literal_application.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/296/{{ revealButtonHref }}
lib/Language/PureScript/Backend/Lua/Optimizer.hshttps://github.com/purescript-lua/purescript-lua/pull/296/files#diff-729235f45985a9f15089eee44d4ee219effa1f8365a3359452ff51c908fe5e41
View file https://github.com/purescript-lua/purescript-lua/blob/9ab5262b3fb3c2d161e836fa3b81a5403636b1bb/lib/Language/PureScript/Backend/Lua/Optimizer.hs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/296/{{ revealButtonHref }}
https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-729235f45985a9f15089eee44d4ee219effa1f8365a3359452ff51c908fe5e41
https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-729235f45985a9f15089eee44d4ee219effa1f8365a3359452ff51c908fe5e41
https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-729235f45985a9f15089eee44d4ee219effa1f8365a3359452ff51c908fe5e41
https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-729235f45985a9f15089eee44d4ee219effa1f8365a3359452ff51c908fe5e41
https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-729235f45985a9f15089eee44d4ee219effa1f8365a3359452ff51c908fe5e41
https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-729235f45985a9f15089eee44d4ee219effa1f8365a3359452ff51c908fe5e41
https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-729235f45985a9f15089eee44d4ee219effa1f8365a3359452ff51c908fe5e41
https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-729235f45985a9f15089eee44d4ee219effa1f8365a3359452ff51c908fe5e41
https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-729235f45985a9f15089eee44d4ee219effa1f8365a3359452ff51c908fe5e41
https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-729235f45985a9f15089eee44d4ee219effa1f8365a3359452ff51c908fe5e41
https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-729235f45985a9f15089eee44d4ee219effa1f8365a3359452ff51c908fe5e41
https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-729235f45985a9f15089eee44d4ee219effa1f8365a3359452ff51c908fe5e41
https://github.com/purescript-lua/purescript-lua/pull/296/files#diff-729235f45985a9f15089eee44d4ee219effa1f8365a3359452ff51c908fe5e41
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/296/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.