René's URL Explorer Experiment


Title: Generalise deep-nesting breaker to any monad + applicative spines (#108) by Unisay · Pull Request #110 · purescript-lua/purescript-lua · GitHub

Open Graph Title: Generalise deep-nesting breaker to any monad + applicative spines (#108) by Unisay · Pull Request #110 · purescript-lua/purescript-lua

X Title: Generalise deep-nesting breaker to any monad + applicative spines (#108) by Unisay · Pull Request #110 · purescript-lua/purescript-lua

Description: Closes #108. Problem FlattenDeepBinds flattens deep nesting that would otherwise overflow Lua 5.1's parser-nesting cap (~200 levels). It recognised deep chains by instance name — Control.Bind.bind/discard, or a Bind dictionary shape. That recognition is precise but brittle and incomplete: The State-transformer miss fixed in #107 was exactly a recognition gap. Applicative chains (ado/apply, =< ...) chain, not just a recognised bind. This deletes the entire recogniser/resolution machinery (isBindHead, headReducesToBind, denotes, isBindDict, peelAlias, the Control.Bind name constants, mkResolve/topLevel/letLocals, and the threaded resolve parameter — ~200 lines). Existing bind goldens are unchanged: same structural shape → identical lambda-lift. Now also covers non-bind CPS / bracket / with-style nesting. Strategy B — application-spine sequentialisation (new). Handles contiguous App spines whose depth is in a value-argument position: ado/apply, =<, any nested call spine. It peels the deepest application path and rebuilds it bottom-up — Lua's evaluation order for these spines — sealing the accumulator into a fresh $tmp local every segmentSize frames. Segmentation (not full A-normalisation) is required because there are two Lua 5.1 per-function limits: a naive full ANF flattens the parser nesting but then overflows the 200-local cap (~300 locals for a 300-deep spine). Segmenting every segmentSize frames bounds both at once: each segment nests ≤ segmentSize deep and the local count is ≈ depth / segmentSize. Dispatch tries A first; a bind chain hides its depth under lambdas, so its application-spine depth is tiny and B only ever sees the remaining deep App spines — the two are naturally disjoint. What is not replaced MagicDo (Effect/ST imperative lowering) is a different kind of solution (local x = m() is only valid where computations are thunks); kept, still runs first, still consumes Effect/ST chains before the general breaker sees them. NestingCheck (post-codegen backstop) is unchanged. Deep case trees (nested if/then/else) need branch- and laziness-aware hoisting; left on NestingCheck as a residual follow-up. Soundness Lua is strict, so every App callee and argument is evaluated regardless of use. Strategy B sequentialises strict positions in evaluation order and never hoists across Abs/branch boundaries, so it preserves evaluation order and divergence. Strategy A only relocates continuations and forwards live variables by name — it never reorders, drops, or duplicates a call. The pass runs after renameShadowedNames, so the freshly-named $kont/$tmp binders shift no de Bruijn index. Tests Structural-recognition unit: a chain whose head is not a bind now flattens (proves the name-gate is gone). Strategy-B units + 200-example Hedgehog properties for both left- and right-nested spines: free-reference preservation, idempotence, nesting-depth reduction. Three runnable goldens whose generated Lua loads and evaluates under stock Lua 5.1 (eval oracle): LongCallbackChain (A) — recursive-guarded non-bind CPS combinator, ~300 deep → 300. LongApplyChain (B) — *> applicative spine, ~300 deep → (Just 300). LongBindFlipped (B) — =<< spine, ~300 deep → (Just 301). Full suite green (313 examples, 0 failures); no existing golden churned. fourmolu/hlint clean.

Open Graph Description: Closes #108. Problem FlattenDeepBinds flattens deep nesting that would otherwise overflow Lua 5.1's parser-nesting cap (~200 levels). It recognised deep chains by instance name — Control.Bind.b...

X Description: Closes #108. Problem FlattenDeepBinds flattens deep nesting that would otherwise overflow Lua 5.1&#39;s parser-nesting cap (~200 levels). It recognised deep chains by instance name — Control.Bi...

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

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:71ae8d70-25aa-a7b9-2f2b-5cb2880c3f8d
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idE34E:C2718:9C99BA:CC3A2E:6B00E490
html-safe-nonce3f5ee202eee35cb056ce725bfd323b16ac25150f5d9ddef98f19378e161176b8
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzRFOkMyNzE4OjlDOTlCQTpDQzNBMkU6NkIwMEU0OTAiLCJ2aXNpdG9yX2lkIjoiNzM1NzA2NTg3OTcyMjk3ODcyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacd660ace425f8e00075fbd3375324876b38888b5f1cf4a22e020179bfb78c3cc8
hovercard-subject-tagpull_request:3914826899
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/110/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 #108. Problem FlattenDeepBinds flattens deep nesting that would otherwise overflow Lua 5.1's parser-nesting cap (~200 levels). It recognised deep chains by instance name — Control.Bind.b...
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/110/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpurescript-lua%2Fpurescript-lua%2Fpull%2F110%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%2F110%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/110/files
Reloadhttps://github.com/purescript-lua/purescript-lua/pull/110/files
Reloadhttps://github.com/purescript-lua/purescript-lua/pull/110/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-108/general-nesting-breakerhttps://github.com/purescript-lua/purescript-lua/tree/issue-108/general-nesting-breaker
Conversation 9 https://github.com/purescript-lua/purescript-lua/pull/110
Commits 2 https://github.com/purescript-lua/purescript-lua/pull/110/commits
Checks 2 https://github.com/purescript-lua/purescript-lua/pull/110/checks
Files changed https://github.com/purescript-lua/purescript-lua/pull/110/files
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/110/files
Generalise deep-nesting breaker to any monad + applicative spines (#108) https://github.com/purescript-lua/purescript-lua/pull/110/files#top
Show all changes 2 commits https://github.com/purescript-lua/purescript-lua/pull/110/files
ec406b4 feat: generalise deep-nesting breaker to any monad + applicative spin… Unisay Jun 22, 2026 https://github.com/purescript-lua/purescript-lua/pull/110/commits/ec406b493b990636f21768077afec0c8b8fadb1d
f98a857 docs: address Copilot review on PR #110 Unisay Jun 22, 2026 https://github.com/purescript-lua/purescript-lua/pull/110/commits/f98a8573334a28be6df8ed21a5a0d9aa3ce423f3
Clear filters https://github.com/purescript-lua/purescript-lua/pull/110/files
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/110/files
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/110/files
QUIRKS.md https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-e829c580d06215599e6ce7868033ec1082f0c45c0e4d8aca64dc1c3a3da0d6c3
Main.hs https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-0112bebea0de3c81e028aa03d5c02c142338c604573ce86df55f0791de47af36
FlattenDeepBinds.hs https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-251ee7bffe05bb3ffd516b71d667bc26aaa280ea5e51249f946b3aabf1f959e8
Optimizer.hs https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-487ead9d0ca9c3e6f68e23c604b0ae9070089e0dd0f7d214cdce5fbc878f3315
Spec.hs https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-729ac8bbecf79c0819bb08de55092d33ff5c719d7944fb99e3e688742c9454ab
Test.purs https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-b7d904b5fcd446f9841dbc02ac026b6a9b3fde1cd86e7d18aeb47213cf59edf3
Test.purs https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-9d6444fbaca70832c2ac432d4992f7d75c1234c2d67b68cf995aaf29836edf43
Test.purs https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-60e74071a56d991b97ac1e2f98e5f4a233e950b9133587d29b7a60c4b8486c18
corefn.json https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-ff98fe5b103aea5e17352a7ab335a3b4dbbb60af4f98da72bfd632fa6402b74b
.gitignore https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-89def3d6133fe7559303220adfbcf9c2438effe38095b680da1425555e39fe3d
golden.txt https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-a7197f465f970299ea216027836885b3031dd75d616447fbfe7da8a76fd81552
golden.ir https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-6dd832f0599e4565be9fba3ebf138337f62b76ef432e4de9943388ca4b187b04
golden.lua https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-3058caa776257034fc5c6caf6cdcd1823934a0ed43d330ebdb6e26da662cf83e
corefn.json https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-bbf0ef064e9c7c9792c4fdaa726c94dfbb6f781f9bea05bc0c2d24a911a2e7f5
.gitignore https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-7ba0bee42036f1fba4d4c72009a5a3e4db34abc68674215a9d2c76712b1c7282
golden.txt https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-3c2191489f20007295c4e2f7f6d15f698593a560fcd0c8fba54b796e74f870ed
golden.ir https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-eba9620c8d2b8c56b9251abc58b7505831f8499b1f53fad731c19446d5d29c2e
golden.lua https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-ed682b7874cb77c82d884b944cd048645092642e7fbac65460891338ad694785
corefn.json https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-7e3167b2674f7b2a5d68706298bfb53aaaa8a2d546cb19ea32af2a1d6c709458
.gitignore https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-a119d4d75adc458be5f81cf368a6db066e174081f0e6c38030a897d3fae0045b
golden.txt https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-3238eb456b5688654ca09bc6f784f798c10730725b12a81d1206f5663264171c
golden.ir https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-ce61e5ff69c413ad0c200ac100302efe37a9755b081dd33467d21b12371cebf1
golden.lua https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-0f80457c0b35d0736c4041d3b36ae67c88c3cce1cb9d8f8114bb21515291c8e2
docs/QUIRKS.mdhttps://github.com/purescript-lua/purescript-lua/pull/110/files#diff-e829c580d06215599e6ce7868033ec1082f0c45c0e4d8aca64dc1c3a3da0d6c3
View file https://github.com/purescript-lua/purescript-lua/blob/f98a8573334a28be6df8ed21a5a0d9aa3ce423f3/docs/QUIRKS.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/110/{{ revealButtonHref }}
https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-e829c580d06215599e6ce7868033ec1082f0c45c0e4d8aca64dc1c3a3da0d6c3
https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-e829c580d06215599e6ce7868033ec1082f0c45c0e4d8aca64dc1c3a3da0d6c3
exe/Main.hshttps://github.com/purescript-lua/purescript-lua/pull/110/files#diff-0112bebea0de3c81e028aa03d5c02c142338c604573ce86df55f0791de47af36
View file https://github.com/purescript-lua/purescript-lua/blob/f98a8573334a28be6df8ed21a5a0d9aa3ce423f3/exe/Main.hs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/purescript-lua/purescript-lua/pull/110/{{ revealButtonHref }}
https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-0112bebea0de3c81e028aa03d5c02c142338c604573ce86df55f0791de47af36
lib/Language/PureScript/Backend/IR/FlattenDeepBinds.hshttps://github.com/purescript-lua/purescript-lua/pull/110/files#diff-251ee7bffe05bb3ffd516b71d667bc26aaa280ea5e51249f946b3aabf1f959e8
View file https://github.com/purescript-lua/purescript-lua/blob/f98a8573334a28be6df8ed21a5a0d9aa3ce423f3/lib/Language/PureScript/Backend/IR/FlattenDeepBinds.hs
Open in desktop https://desktop.github.com
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/110/files
lib/Language/PureScript/Backend/IR/Optimizer.hshttps://github.com/purescript-lua/purescript-lua/pull/110/files#diff-487ead9d0ca9c3e6f68e23c604b0ae9070089e0dd0f7d214cdce5fbc878f3315
View file https://github.com/purescript-lua/purescript-lua/blob/f98a8573334a28be6df8ed21a5a0d9aa3ce423f3/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/110/{{ revealButtonHref }}
https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-487ead9d0ca9c3e6f68e23c604b0ae9070089e0dd0f7d214cdce5fbc878f3315
https://github.com/purescript-lua/purescript-lua/pull/110/files#diff-487ead9d0ca9c3e6f68e23c604b0ae9070089e0dd0f7d214cdce5fbc878f3315
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/110/files
Please reload this pagehttps://github.com/purescript-lua/purescript-lua/pull/110/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.