Title: Budgeted call-site inlining of dictionary methods to collapse non-Effect/ST monadic chains · Issue #180 · purescript-lua/purescript-lua · GitHub
Open Graph Title: Budgeted call-site inlining of dictionary methods to collapse non-Effect/ST monadic chains · Issue #180 · purescript-lua/purescript-lua
X Title: Budgeted call-site inlining of dictionary methods to collapse non-Effect/ST monadic chains · Issue #180 · purescript-lua/purescript-lua
Description: Problem Monadic code outside Effect/ST — Writer/State/Either/Maybe chains — compiles to nested closure chains: measured 63x against the equivalent statement sequence (1e6 iterations of a 3-bind chain, PUC 5.1). magicDo covers Effect/ST o...
Open Graph Description: Problem Monadic code outside Effect/ST — Writer/State/Either/Maybe chains — compiles to nested closure chains: measured 63x against the equivalent statement sequence (1e6 iterations of a 3-bind cha...
X Description: Problem Monadic code outside Effect/ST — Writer/State/Either/Maybe chains — compiles to nested closure chains: measured 63x against the equivalent statement sequence (1e6 iterations of a 3-bind cha...
Opengraph URL: https://github.com/purescript-lua/purescript-lua/issues/180
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Budgeted call-site inlining of dictionary methods to collapse non-Effect/ST monadic chains","articleBody":"## Problem\n\nMonadic code outside Effect/ST — Writer/State/Either/Maybe chains — compiles to nested closure chains: measured 63x against the equivalent statement sequence (1e6 iterations of a 3-bind chain, PUC 5.1). magicDo covers Effect/ST only, and flattenDeepBinds fixes nesting depth (the parser limit), not cost. The cure is specialization: inline the concrete dictionary's `bind`/`apply`/`map` into the call site, beta-reduce, and let case-of-known-constructor (#177) collapse the constructor matches into straight-line code.\n\nThe current heuristic refuses by construction: `isInlinableExpr` accepts refs, literals, annotations, and used-once bindings — a dictionary method is a multi-use non-trivial lambda, so it is never inlined into call sites.\n\n## Approach\n\nGHC-style budgeted call-site inlining: inline a multi-use binding into a specific saturated application site when (a) the head resolves to a lambda, including through `ObjectProp` of a known top-level dictionary literal, (b) the application is saturated with respect to manifest arity, and (c) the inlinee's size is within a tunable budget (the analogue of GHC's unfolding-use-threshold), with growth accounted per fixpoint round — the change-flag infrastructure from #144 is in place. Separately, projection through a Ref: `ObjectProp (Ref dict) \"bind\"` resolves to the method expression by looking at the binding's RHS without inlining the whole dictionary.\n\n## Prerequisites / Relations\n\nThe prerequisites that complete the cascade are #177 (known-constructor folds) and #178 (primops give arithmetic inside chains a bottom); with #177 alone the Maybe/Either case is already useful, collapsing into if-chains. Several open issues interact: #167 is a discipline prerequisite (without let-binding non-trivial arguments, aggressive inlining multiplies work); #143 must be fixed with or before this, since the heuristic stands on reference counts that go stale during inlining; #142 becomes visible because more inlining means more fixpoint pressure on optimizer compile time; and the budget must interact predictably with the `@inline` annotations of #169 and #171.\n\n## Verification / Measurement\n\nThe win is measured by #172's bind-chain macrobenchmark — the 63x case — with the `LongWriterBind`/`LongStateBind` goldens as ready-made material. Code growth is the main risk, bounded by the size budget and watched via `golden.lua` sizes. Because the transform is behaviour-preserving, runtime output must stay identical: the `eval` goldens must not move.\n","author":{"url":"https://github.com/Unisay","@type":"Person","name":"Unisay"},"datePublished":"2026-07-06T10:38:09Z","url":"https://github.com/purescript-lua/purescript-lua/issues/180"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:703cd5bc-cca0-1c1b-425c-d46c6ed73c2d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D088:311EEE:7974BF:A3666E:6B00DB75 |
| html-safe-nonce | 54654b8acaf8b9a54eff1f35585d7a5292d00bdf9c3e43f1c1b6c261e334ac3d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMDg4OjMxMUVFRTo3OTc0QkY6QTM2NjZFOjZCMDBEQjc1IiwidmlzaXRvcl9pZCI6IjE2MTY2OTM2ODk5MzE4NDg1NjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e674982655883b8015a7a172a50cda049d865834ed8e3df742102fbfb2ccd441 |
| hovercard-subject-tag | issue:4818292833 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/purescript-lua/purescript-lua/180/issue_layout |
| twitter:image | https://opengraph.githubassets.com/099e3d3717b2a582cfd2823673ffa69d2ac75052d09b9086338479cb2012b06f/purescript-lua/purescript-lua/issues/180 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/099e3d3717b2a582cfd2823673ffa69d2ac75052d09b9086338479cb2012b06f/purescript-lua/purescript-lua/issues/180 |
| og:image:alt | Problem Monadic code outside Effect/ST — Writer/State/Either/Maybe chains — compiles to nested closure chains: measured 63x against the equivalent statement sequence (1e6 iterations of a 3-bind cha... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Unisay |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| turbo-cache-control | no-preview |
| go-import | github.com/purescript-lua/purescript-lua git https://github.com/purescript-lua/purescript-lua.git |
| octolytics-dimension-user_id | 131581790 |
| octolytics-dimension-user_login | purescript-lua |
| octolytics-dimension-repository_id | 587200487 |
| octolytics-dimension-repository_nwo | purescript-lua/purescript-lua |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 587200487 |
| octolytics-dimension-repository_network_root_nwo | purescript-lua/purescript-lua |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width