chore: add treefmt formatting (nix fmt + pre-commit + CI check)#13
Merged
Conversation
Wire treefmt via treefmt-nix: nixfmt, dhall format, purs-tidy (.tidyrc.json) and LuaFormatter for the FFI (.lua-format, kept over StyLua because it preserves the parentheses pslua's parser needs). `nix fmt` formats; the dev shell installs a content-based pre-commit hook and CI runs `nix fmt && git diff --exit-code` (content-based, since the in-place formatters bump mtime and would trip treefmt --fail-on-change). Lua lines budget 130 cols, matching the raised `luacheck --max-line-length`. The bulk of the diff is the first format pass.
There was a problem hiding this comment.
Pull request overview
Rolls out standardized formatting for this PureScript→Lua prelude repo via treefmt-nix, including developer ergonomics (pre-commit hook + nix fmt) and CI enforcement, plus an initial formatting pass across the codebase.
Changes:
- Add
treefmt.nix+ treefmt-nix wiring inflake.nixto providenix fmtandchecks.formatting. - Add formatting configs (
.tidyrc.json,.lua-format), update docs/CI to run a content-based format check (nix fmt && git diff --exit-code). - Apply formatter-driven whitespace/layout changes across
*.purs,spago.dhall, and Lua FFI.
Reviewed changes
Copilot reviewed 36 out of 39 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
treefmt.nix |
Defines treefmt programs (nixfmt, dhall, purs-tidy, lua-format) and excludes generated/vendored paths. |
flake.nix |
Adds treefmt-nix input, exposes flake formatter + formatting check, and installs a pre-commit hook in devShell. |
flake.lock |
Locks treefmt-nix input. |
AGENTS.md |
Documents formatting workflow, lint line-length alignment, and rationale for content-based checks. |
.tidyrc.json |
purs-tidy configuration for PureScript formatting. |
.lua-format |
LuaFormatter configuration (2-space indent, column limit tuned for luacheck). |
.gitignore |
Ensures .tidyrc.json and .lua-format are not ignored. |
.github/workflows/ci.yml |
Updates luacheck max line length and adds a format-check step. |
spago.dhall |
Dhall-format normalization. |
test/Test/Main.purs |
purs-tidy formatting pass in tests. |
test/Data/Generic/Rep.purs |
purs-tidy formatting pass in tests. |
src/Record/Unsafe.purs |
purs-tidy formatting pass in FFI imports/types. |
src/Data/Symbol.purs |
purs-tidy formatting pass in function signature layout. |
src/Data/Show/Generic.purs |
purs-tidy formatting pass (instance constraints layout). |
src/Data/Show.purs |
purs-tidy formatting pass (instance chain layout). |
src/Data/Semiring/Generic.purs |
purs-tidy formatting pass (instance constraints/layout). |
src/Data/Semiring.purs |
purs-tidy formatting pass (record instance constraints). |
src/Data/Semigroup/Generic.purs |
purs-tidy formatting pass (instance constraints + signature layout). |
src/Data/Semigroup.purs |
purs-tidy formatting pass (record instance constraints). |
src/Data/Semigroup.lua |
LuaFormatter formatting pass (keeps exported expressions parenthesized). |
src/Data/Ring/Generic.purs |
purs-tidy formatting pass (instance constraints/layout). |
src/Data/Ring.purs |
purs-tidy formatting pass (record instance constraints + class header layout). |
src/Data/Reflectable.purs |
purs-tidy formatting pass (signature layout). |
src/Data/Ord/Generic.purs |
purs-tidy formatting pass (instance constraints + signature layout). |
src/Data/Ord.purs |
purs-tidy formatting pass (FFI import signature layout). |
src/Data/Monoid/Multiplicative.purs |
purs-tidy formatting pass (derive signature layout). |
src/Data/Monoid/Generic.purs |
purs-tidy formatting pass (instance constraints/layout). |
src/Data/Monoid.purs |
purs-tidy formatting pass (record instance constraints + class header layout). |
src/Data/HeytingAlgebra/Generic.purs |
purs-tidy formatting pass (instance constraints/layout + signature layout). |
src/Data/HeytingAlgebra.purs |
purs-tidy formatting pass (record instance constraints + class kind signature layout). |
src/Data/Generic/Rep.purs |
purs-tidy formatting pass (string concatenation layout). |
src/Data/Eq/Generic.purs |
purs-tidy formatting pass (instance constraints/layout). |
src/Data/Eq.purs |
purs-tidy formatting pass (FFI import signature layout). |
src/Data/CommutativeRing.purs |
purs-tidy formatting pass (record instance constraints + class header layout). |
src/Data/Bounded/Generic.purs |
purs-tidy formatting pass (instance constraints/layout). |
src/Data/Bounded.purs |
purs-tidy formatting pass (class header layout). |
src/Data/BooleanAlgebra.purs |
purs-tidy formatting pass (record instance constraints + class kind signature/layout). |
src/Control/Bind.purs |
purs-tidy formatting pass (signature layout). |
src/Control/Apply.purs |
purs-tidy formatting pass (signature layout). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Roll the ecosystem formatting setup (ADR 0007, piloted in purescript-lua/purescript-lua-effect#6) onto this fork.
Tooling. Copies
treefmt.nix/.tidyrc.json/.lua-formatand wires treefmt-nix into the flake:nix fmtformats,checks.formattingis exposed, the dev shell installs a content-based pre-commit hook, and CI gains a format-check step. The check is content-based (nix fmt && git diff --exit-code) rather thantreefmt --ci, since the in-place formatters bump mtime even when content is unchanged. LuaFormatter is kept over StyLua because it preserves the parentheses pslua's foreign-file parser requires;luacheck --max-line-lengthraised to 130 to match.Diff. The bulk is the first
nix fmtpass over*.pursand the*.luaFFI. Verified locally: build +luacheck --max-line-length 130green.