Title: Wire fourmolu into treefmt so nix fmt covers Haskell · Issue #357 · purescript-lua/purescript-lua · GitHub
Open Graph Title: Wire fourmolu into treefmt so nix fmt covers Haskell · Issue #357 · purescript-lua/purescript-lua
X Title: Wire fourmolu into treefmt so nix fmt covers Haskell · Issue #357 · purescript-lua/purescript-lua
Description: Problem nix fmt runs treefmt (configured in treefmt.nix) over Cabal, Nix, YAML and Dhall files. Haskell is deliberately excluded, and the exclusion is the first thing the file says: # Haskell (fourmolu) is deliberately NOT wired into `ni...
Open Graph Description: Problem nix fmt runs treefmt (configured in treefmt.nix) over Cabal, Nix, YAML and Dhall files. Haskell is deliberately excluded, and the exclusion is the first thing the file says: # Haskell (four...
X Description: Problem nix fmt runs treefmt (configured in treefmt.nix) over Cabal, Nix, YAML and Dhall files. Haskell is deliberately excluded, and the exclusion is the first thing the file says: # Haskell (four...
Opengraph URL: https://github.com/purescript-lua/purescript-lua/issues/357
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Wire fourmolu into treefmt so nix fmt covers Haskell","articleBody":"## Problem\n\n`nix fmt` runs treefmt (configured in `treefmt.nix`) over Cabal, Nix, YAML and Dhall files. Haskell is deliberately excluded, and the exclusion is the first thing the file says:\n\n```nix\n # Haskell (fourmolu) is deliberately NOT wired into `nix fmt`. fourmolu's\n # --haddock-style is global (single-line | multi-line | multi-line-compact)\n # with no per-comment or by-length mode, so any choice rewrites the\n # hand-authored Haddock — single-line line-prefixes long block comments\n # (annoying to copy), while multi-line bloats short ones. The source keeps a\n # deliberate mix (short `-- |`, long `{- | … -}`), so Haskell stays a manual\n # `fourmolu -i lib/ exe/ test/` step the author runs when they choose.\n```\n\nThat rationale no longer holds, for two measurable reasons.\n\nA global style is already chosen and already applied. `fourmolu.yaml` pins `haddock-style: multi-line`, and the tree is at fourmolu's fixed point under it — `fourmolu --mode check lib/ exe/ test/` exits 0 with nothing to report. So wiring fourmolu into `nix fmt` is zero-churn today; the cost the comment warns about has already been paid by the manual step.\n\nAnd the stated objection is false against the fourmolu in use (0.19.0.1). `haddock-style` governs how *multi-line* Haddock is rendered; it does not expand a short one-line `-- |` into a block. The tree carries 169 `-- |` occurrences alongside 492 `{- |` ones in `lib/ exe/ test/` and still passes `--mode check` under `haddock-style: multi-line`, so the \"deliberate mix\" is preserved by fourmolu rather than threatened by it.\n\n## Approach\n\nEnable the formatter in `treefmt.nix` and delete the stale comment:\n\n```nix\n programs.fourmolu.enable = true;\n```\n\ntreefmt-nix's module invokes it as `fourmolu -i -c` over `*.hs` and adds `--ghc-opt -X\u003cExt>` for each entry in `programs.fourmolu.ghcOpts` (default `BangPatterns`, `PatternSynonyms`, `TypeApplications`). fourmolu finds `fourmolu.yaml` and picks up `default-extensions` from the Cabal file on its own, so no further configuration should be needed — but that is the thing to verify, since a parse difference between the treefmt invocation and the manual one would show up as churn rather than as an error.\n\nOne coupling is worth making explicit rather than inheriting. The module takes its binary from nixpkgs (`haskellPackages.fourmolu`), while the dev shell's `fourmolu` comes from the flake's haskell.nix tooling. Both currently resolve to 0.19.0.1, so they agree — but they can drift independently on a `nix flake update`, and two fourmolu versions formatting the same tree would fight: `nix fmt` would rewrite what the manual step just wrote, and the `format` CI job (`nix fmt && git diff --exit-code`) would fail on a tree that is clean under the dev-shell binary. Point `programs.fourmolu.package` at the same derivation the dev shell uses so there is one fourmolu in the repo.\n\nOnce `nix fmt` covers Haskell, the manual `fourmolu -i lib/ exe/ test/` step in `CLAUDE.md` and `docs/` becomes redundant and should be folded into `nix fmt` there too.\n\n## Prerequisites / Relations\n\nIndependent. Touches `treefmt.nix`, possibly `flake.nix` for the package pin, and the formatting instructions in `CLAUDE.md`. No compiler code involved.\n\n## Acceptance criteria\n\n- `nix fmt` formats Haskell, and running it on a clean checkout leaves the tree unchanged (which is what the `format` CI job already asserts with `git diff --exit-code`).\n- `nix fmt` and a direct `fourmolu -i` use the same fourmolu build, so neither can undo the other after a flake update.\n- The formatting instructions no longer describe Haskell as a separate manual step.\n","author":{"url":"https://github.com/Unisay","@type":"Person","name":"Unisay"},"datePublished":"2026-07-29T17:12:01Z","url":"https://github.com/purescript-lua/purescript-lua/issues/357"}
| 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:303bece9-c856-b1fe-6077-3d880b92e9eb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E962:28815B:6D6B7C:93E3F8:6B00D93F |
| html-safe-nonce | aa3f64e1a852b6b798bc2181b99794173ffaa12dbec65649dba4c51f71df75cc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTYyOjI4ODE1Qjo2RDZCN0M6OTNFM0Y4OjZCMDBEOTNGIiwidmlzaXRvcl9pZCI6IjY4NzY3ODAzMTI0NjcxMzQ3ODMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 02b5b783d58cd526a83868d7b41b5c5d6ac55ed909a048c0c0c9b4df425751dc |
| hovercard-subject-tag | issue:5011839126 |
| 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/357/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0742141750048d1bb7a2f6d396fb2920f6283de5dfafaf0651c84b487e1dbab3/purescript-lua/purescript-lua/issues/357 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0742141750048d1bb7a2f6d396fb2920f6283de5dfafaf0651c84b487e1dbab3/purescript-lua/purescript-lua/issues/357 |
| og:image:alt | Problem nix fmt runs treefmt (configured in treefmt.nix) over Cabal, Nix, YAML and Dhall files. Haskell is deliberately excluded, and the exclusion is the first thing the file says: # Haskell (four... |
| 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