Title: Replace the single-metric case column heuristic with Maranget's composite pbaN · Issue #237 · purescript-lua/purescript-lua · GitHub
Open Graph Title: Replace the single-metric case column heuristic with Maranget's composite pbaN · Issue #237 · purescript-lua/purescript-lua
X Title: Replace the single-metric case column heuristic with Maranget's composite pbaN · Issue #237 · purescript-lua/purescript-lua
Description: Problem mkCase (Backend/IR.hs) builds decision trees by Jules Jacobs's algorithm and already prunes redundant tests through MatchHistory. Its column-selection heuristic, matchChosenByHeuristic (IR.hs:571), uses a single metric: pick the ...
Open Graph Description: Problem mkCase (Backend/IR.hs) builds decision trees by Jules Jacobs's algorithm and already prunes redundant tests through MatchHistory. Its column-selection heuristic, matchChosenByHeuristic (IR....
X Description: Problem mkCase (Backend/IR.hs) builds decision trees by Jules Jacobs's algorithm and already prunes redundant tests through MatchHistory. Its column-selection heuristic, matchChosenByHeuristic ...
Opengraph URL: https://github.com/purescript-lua/purescript-lua/issues/237
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Replace the single-metric case column heuristic with Maranget's composite pbaN","articleBody":"## Problem\n\n`mkCase` (`Backend/IR.hs`) builds decision trees by Jules Jacobs's algorithm and already prunes redundant tests through `MatchHistory`. Its column-selection heuristic, `matchChosenByHeuristic` (`IR.hs:571`), uses a single metric: pick the match present in the most other clauses. Maranget's composite `pbaN` (\"Compiling Pattern Matching to Good Decision Trees\") is sharper: `p` neededness (longest prefix of matching rows), `b` fewest distinct constructors (retire a column sooner), `a` fewest future sub-tests (look-ahead), `N` leftmost tie-break. On complex matches the composite produces smaller trees.\n\n## Approach\n\nReplace the single-metric selection in `matchChosenByHeuristic` with the `pbaN` composite, scoring each candidate column on the four sub-metrics in order and breaking ties leftmost. The surrounding decision-tree construction and `MatchHistory` pruning are unchanged; this swaps only the column choice.\n\n## Prerequisites / Relations\n\nIndependent. Touches the same code as #184 (which extends `MatchHistory` to literal patterns and accumulates negative knowledge) but on an orthogonal axis: #184 is test pruning, this is column selection. They compose and neither blocks the other. A related trick, \"leaf-as-function\" (wrap a clause RHS shared across a wildcard fallthrough in a function to avoid duplicating its body), is worth a look only if a corpus survey shows pslua duplicates such bodies, noted as a possible follow-up, not part of this issue.\n\n## Verification / Measurement\n\nA match whose column ordering makes `pbaN` and the current metric disagree compiles to a smaller tree (fewer tests) under the new heuristic, on a constructed multi-column case; eval goldens across the corpus stay unchanged, since only the tree shape moves, not the semantics. Code-size delta through #172.\n","author":{"url":"https://github.com/Unisay","@type":"Person","name":"Unisay"},"datePublished":"2026-07-11T12:02:47Z","url":"https://github.com/purescript-lua/purescript-lua/issues/237"}
| 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:59c45d3a-1469-84b2-787e-1955c2404536 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9040:317608:776ADE:99014B:6B00E44A |
| html-safe-nonce | 33fdf030209d3b57d6d3e2cf89826bda90e7bb6c7e62a324a4b4c68dd75f64fb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDQwOjMxNzYwODo3NzZBREU6OTkwMTRCOjZCMDBFNDRBIiwidmlzaXRvcl9pZCI6IjkyMDYxMzkzMzI3NzgzMjA5NzAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 163872e5d950d8099160c8c937582932aa7f6a6f6447430ca67fd094f1a83f02 |
| hovercard-subject-tag | issue:4862140368 |
| 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/237/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c1ce4059d9fd7a354192639b7abbf2c12fe11795eced8d4f7e46d4bbadc84504/purescript-lua/purescript-lua/issues/237 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c1ce4059d9fd7a354192639b7abbf2c12fe11795eced8d4f7e46d4bbadc84504/purescript-lua/purescript-lua/issues/237 |
| og:image:alt | Problem mkCase (Backend/IR.hs) builds decision trees by Jules Jacobs's algorithm and already prunes redundant tests through MatchHistory. Its column-selection heuristic, matchChosenByHeuristic (IR.... |
| 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 | 27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14 |
| 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 | 624179fb8b88d26ba5bba08894eb60a1c5a1d93d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width