Title: Float computed dictionary applications so transformer chains collapse under the directive pack · Issue #329 · purescript-lua/purescript-lua · GitHub
Open Graph Title: Float computed dictionary applications so transformer chains collapse under the directive pack · Issue #329 · purescript-lua/purescript-lua
X Title: Float computed dictionary applications so transformer chains collapse under the directive pack · Issue #329 · purescript-lua/purescript-lua
Description: Problem With the default directive pack (#242), monad-transformer chains still do not collapse, and the 300-deep stress goldens grow slightly instead (Golden.LongStackBind 67,870 → 70,406 bytes, Golden.LongStateBind 75,735 → 78,463, Gold...
Open Graph Description: Problem With the default directive pack (#242), monad-transformer chains still do not collapse, and the 300-deep stress goldens grow slightly instead (Golden.LongStackBind 67,870 → 70,406 bytes, Go...
X Description: Problem With the default directive pack (#242), monad-transformer chains still do not collapse, and the 300-deep stress goldens grow slightly instead (Golden.LongStackBind 67,870 → 70,406 bytes, Go...
Opengraph URL: https://github.com/purescript-lua/purescript-lua/issues/329
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Float computed dictionary applications so transformer chains collapse under the directive pack","articleBody":"## Problem\n\nWith the default directive pack (#242), monad-transformer chains still do not collapse, and the 300-deep stress goldens grow slightly instead (`Golden.LongStackBind` 67,870 → 70,406 bytes, `Golden.LongStateBind` 75,735 → 78,463, `Golden.LongWriterBind` 57,000 → 57,422 in PR #327). The blocker is deliberate: directive derivation (#241) refuses to derive over a computed argument, because pasting `bind (bindExceptT monadIdentity)` — a dictionary built by applying the transformer's instance function — would re-run that construction at every one of ~300 sites (PR #327 added this work-free-argument guard after observing exactly that, +40% on the ExceptT golden). So the specialization stays a shared binding, the sites keep calling it, and the chain never meets the constructor folds.\n\n## Approach\n\nFloat the computed dictionary application to a top-level value binding during optimization: in a whole-program pipeline `bindExceptT monadIdentity` is a constant applicative form, so materializing it once as a named binding turns the derivation's argument into a plain reference — which the work-free guard accepts — and the existing cascade (derive, paste, resolve the field, fold) proceeds. This is the optimizer-side analogue of the float purs's own CSE emits for repeated dictionary applications in source. Recursive transformer dictionaries (the `StateT`-over-`Except` knot) additionally need the specialized instance methods unfolded through the newtype-shaped wrappers before the folds connect, so measure how far the float alone goes before deciding whether method-level specialization is also required.\n\n## Prerequisites / Relations\n\nFollow-up to #242 / PR #327 (the guard that makes this the remaining blocker). Related: #326 (per-site dictionary field reads when the method is over budget — its sharing-repair pass would also clean up shapes this float exposes) and the #206 observation that recursive StateT dictionaries block the CPR-adjacent collapses.\n\n## Verification / Measurement\n\nThe three transformer stress goldens return to at most their pre-pack sizes, ideally collapsing like the Maybe/Either chains did; eval goldens unchanged; corpus size delta reported through the bench harness (#172) counters, which must not regress on any non-transformer artifact.\n","author":{"url":"https://github.com/Unisay","@type":"Person","name":"Unisay"},"datePublished":"2026-07-28T10:15:28Z","url":"https://github.com/purescript-lua/purescript-lua/issues/329"}
| 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:ce37f035-26da-52d6-2439-3048fb0bb44c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C1C2:3F8AB1:853242:AD491C:6B00D942 |
| html-safe-nonce | bd3eef2b05cea56a6b5439815dbf79ffa554e94b9b0b556b43b902c17f388555 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMUMyOjNGOEFCMTo4NTMyNDI6QUQ0OTFDOjZCMDBEOTQyIiwidmlzaXRvcl9pZCI6IjM4NjIwNTI5ODU0MDgzNzkyMDIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d79c50b8f0efb84b3646b26b6339b3af2f265d6984569f192f234427371c36d7 |
| hovercard-subject-tag | issue:4997430997 |
| 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/329/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1cf2b0f89ab8bd0e5f10327e83c5eb5404aaa5eb245a25a4b6121b5dc000eef1/purescript-lua/purescript-lua/issues/329 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1cf2b0f89ab8bd0e5f10327e83c5eb5404aaa5eb245a25a4b6121b5dc000eef1/purescript-lua/purescript-lua/issues/329 |
| og:image:alt | Problem With the default directive pack (#242), monad-transformer chains still do not collapse, and the 300-deep stress goldens grow slightly instead (Golden.LongStackBind 67,870 → 70,406 bytes, Go... |
| 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 | a481f62a1e04c9b9bdcb5628230682c66d59006f5b13b080f79cba84a176905b |
| 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 | 84c8c5cc25e2fb7f2308428458538436baecc6d2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width