Title: Array-part constructor representation: {tag, v0, v1} instead of hash-part {$ctor=…, value0=…} · Issue #185 · purescript-lua/purescript-lua · GitHub
Open Graph Title: Array-part constructor representation: {tag, v0, v1} instead of hash-part {$ctor=…, value0=…} · Issue #185 · purescript-lua/purescript-lua
X Title: Array-part constructor representation: {tag, v0, v1} instead of hash-part {$ctor=…, value0=…} · Issue #185 · purescript-lua/purescript-lua
Description: Problem A constructor value compiles to a table with a hash part: {["$ctor"] = "Data.Maybe∷Maybe.Just", value0 = x} — two string keys hashed on every allocation and every field/tag read. Measured (2e6 allocate+match iterations, PUC 5.1):...
Open Graph Description: Problem A constructor value compiles to a table with a hash part: {["$ctor"] = "Data.Maybe∷Maybe.Just", value0 = x} — two string keys hashed on every allocation and every field/tag read. Measured (...
X Description: Problem A constructor value compiles to a table with a hash part: {["$ctor"] = "Data.Maybe∷Maybe.Just", value0 = x} — two string keys hashed on every allocation and every field/...
Opengraph URL: https://github.com/purescript-lua/purescript-lua/issues/185
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Array-part constructor representation: {tag, v0, v1} instead of hash-part {$ctor=…, value0=…}","articleBody":"## Problem\n\nA constructor value compiles to a table with a hash part: `{[\"$ctor\"] = \"Data.Maybe∷Maybe.Just\", value0 = x}` — two string keys hashed on every allocation and every field/tag read. Measured (2e6 allocate+match iterations, PUC 5.1): the array-part representation `{tag, x}` is 1.4x faster and smaller (array part, no hash slots). An anti-result from the same measurements worth recording: switching the tag from an interned string to an integer buys nothing (0.92x — interned strings compare by pointer); the win comes from positional layout, not the tag type.\n\n## Approach\n\n`{TAG_STRING, v₀, v₁}`: tag at `[1]`, fields at `[2..]`. The IR does not change at all — `Ctor`/`ReflectCtor`/`DataArgumentByIndex` are already representation-abstract; this is pure lowering in `Lua.hs` (`ReflectCtor` → `x[1]`, `DataArgumentByIndex i` → `x[i+2]`).\n\n## Prerequisites / Relations\n\nIndependent in the dependency graph — no native blocked-by edge — but scheduled to land late. The representation is FFI-visible: any fork foreign code reading `.value0` / `[\"$ctor\"]` or hand-constructing values of PureScript types breaks silently. Most fork API is representation-abstract (constructors are passed in as parameters, `_codePointAt(just)(nothing)`-style), but a full fork audit is mandatory, plus a major package-set bump, plus a full structural-golden rewrite. Paths where the tag string escapes into output (`Show`-adjacent, generic deriving) need explicit review. Schedule strictly after #178–#181 collect the main wins, so the fork audit runs once.\n\n## Verification / Measurement\n\n~1.4x faster and smaller on the allocate+match microbenchmark (2e6 iterations, PUC 5.1) that is already in #172's set. Eval goldens must not move — the representation flip is semantics-preserving, so the runtime oracle is the safety net that proves no fork or output path silently depended on the old layout.\n\n## Checklist\n\n1. Grep all package-set forks for `value0`/`$ctor` in `.lua` sources; fix or confirm abstract.\n2. Lowering change in `Lua.hs` + golden regeneration.\n3. Eval goldens must not move (semantic oracle).\n4. Major package-set bump, coordinated release.\n","author":{"url":"https://github.com/Unisay","@type":"Person","name":"Unisay"},"datePublished":"2026-07-06T10:50:27Z","url":"https://github.com/purescript-lua/purescript-lua/issues/185"}
| 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:c201311a-c62b-54ae-15cd-0577a8f14311 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A9E8:363D8E:A06AB1:CF4E78:6B00E052 |
| html-safe-nonce | 5731d63f220fe82484efb7bbe076933d7c7e48abfc7a8815be3db44c2076ed72 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOUU4OjM2M0Q4RTpBMDZBQjE6Q0Y0RTc4OjZCMDBFMDUyIiwidmlzaXRvcl9pZCI6IjUyNzU0MTczMzcyNzE5OTMxNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d721ef68c9e350ca76c111f3f62c4cd84ab1bb1628be384b42d0ad84f7aac2f8 |
| hovercard-subject-tag | issue:4818393770 |
| 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/185/issue_layout |
| twitter:image | https://opengraph.githubassets.com/04e3d656fb367986c7b443b3740b7a70fa4db660b983bcff9f6c564735d2db6e/purescript-lua/purescript-lua/issues/185 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/04e3d656fb367986c7b443b3740b7a70fa4db660b983bcff9f6c564735d2db6e/purescript-lua/purescript-lua/issues/185 |
| og:image:alt | Problem A constructor value compiles to a table with a hash part: {["$ctor"] = "Data.Maybe∷Maybe.Just", value0 = x} — two string keys hashed on every allocation and every field/tag read. Measured (... |
| 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