From 5149ee36f501c69b1c780f3ee7c2ad13ab05f3ec Mon Sep 17 00:00:00 2001 From: Finjineersdev Date: Tue, 1 Dec 2026 13:24:56 +0500 Subject: [PATCH] feat(rules): Haskell dist-newstyle and .stack-work Cabal builds into dist-newstyle, and `cabal clean` "cleans up the temporary files and build artifacts stored in the dist-newstyle folder" (https://cabal.readthedocs.io/en/stable/cabal-commands.html). Stack's work directory has "Default: .stack-work" and `stack clean --full` deletes it (https://docs.haskellstack.org/en/stable/configure/yaml/non-project/). Installed dependencies live in ~/.cabal and ~/.stack, so both folders are Safe: the next build recreates them. A project is a folder with cabal.project, stack.yaml or a *.cabal file. Adds haskell.toml to BUNDLED, a Cabal and a Stack match fixture, a nomatch fixture with neither, and the README table row. The rules-check snapshot counts 13 files and 36 artifacts. --- README.md | 1 + .../tests/snapshots/rules-check.json | 4 +-- engine/crates/opensweep-core/src/rules.rs | 1 + .../fixtures/haskell/match/cabal/app.cabal | 0 .../match/cabal/dist-newstyle/build/.keep | 0 .../fixtures/haskell/match/cabal/expected.txt | 1 + .../fixtures/haskell/match/cabal/src/Main.hs | 0 .../match/stack/.stack-work/dist/.keep | 0 .../fixtures/haskell/match/stack/expected.txt | 1 + .../fixtures/haskell/match/stack/package.yaml | 0 .../fixtures/haskell/match/stack/stack.yaml | 0 .../nomatch/no-project-file/.stack-work/.keep | 0 .../haskell/nomatch/no-project-file/README.md | 0 .../no-project-file/dist-newstyle/.keep | 0 engine/rules/haskell.toml | 25 +++++++++++++++++++ 15 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 engine/rules/fixtures/haskell/match/cabal/app.cabal create mode 100644 engine/rules/fixtures/haskell/match/cabal/dist-newstyle/build/.keep create mode 100644 engine/rules/fixtures/haskell/match/cabal/expected.txt create mode 100644 engine/rules/fixtures/haskell/match/cabal/src/Main.hs create mode 100644 engine/rules/fixtures/haskell/match/stack/.stack-work/dist/.keep create mode 100644 engine/rules/fixtures/haskell/match/stack/expected.txt create mode 100644 engine/rules/fixtures/haskell/match/stack/package.yaml create mode 100644 engine/rules/fixtures/haskell/match/stack/stack.yaml create mode 100644 engine/rules/fixtures/haskell/nomatch/no-project-file/.stack-work/.keep create mode 100644 engine/rules/fixtures/haskell/nomatch/no-project-file/README.md create mode 100644 engine/rules/fixtures/haskell/nomatch/no-project-file/dist-newstyle/.keep create mode 100644 engine/rules/haskell.toml diff --git a/README.md b/README.md index e5511c9..b2f01c0 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,7 @@ project runs again, so they are never ticked for you. | Node.js | `.next` `.nuxt` `.svelte-kit` `.turbo` `.parcel-cache` `.angular/cache` `dist` `build` | `node_modules` | | Python | `__pycache__` `.pytest_cache` `.mypy_cache` `.ruff_cache` `.tox` `.nox` | `.venv` `venv` | | Go | | `vendor` | +| Haskell (Cabal and Stack) | `dist-newstyle` `.stack-work` | | | Rust | `target` | | | Java and Kotlin | `target` `build` | `.gradle` | | Flutter and Dart | `build` `.dart_tool` | `ios/Pods` | diff --git a/engine/crates/opensweep-cli/tests/snapshots/rules-check.json b/engine/crates/opensweep-cli/tests/snapshots/rules-check.json index 260f172..9cb636a 100644 --- a/engine/crates/opensweep-cli/tests/snapshots/rules-check.json +++ b/engine/crates/opensweep-cli/tests/snapshots/rules-check.json @@ -1,8 +1,8 @@ [ { - "artifacts": 37, + "artifacts": 39, "command": "rules-check", - "rule_files": 13, + "rule_files": 14, "schema_version": 1 } ] diff --git a/engine/crates/opensweep-core/src/rules.rs b/engine/crates/opensweep-core/src/rules.rs index 5e8c1cd..5881676 100644 --- a/engine/crates/opensweep-core/src/rules.rs +++ b/engine/crates/opensweep-core/src/rules.rs @@ -580,6 +580,7 @@ const BUNDLED: &[(&str, &str)] = &[ ("elixir.toml", include_str!("../../../rules/elixir.toml")), ("flutter.toml", include_str!("../../../rules/flutter.toml")), ("go.toml", include_str!("../../../rules/go.toml")), + ("haskell.toml", include_str!("../../../rules/haskell.toml")), ("java.toml", include_str!("../../../rules/java.toml")), ("node.toml", include_str!("../../../rules/node.toml")), ("php.toml", include_str!("../../../rules/php.toml")), diff --git a/engine/rules/fixtures/haskell/match/cabal/app.cabal b/engine/rules/fixtures/haskell/match/cabal/app.cabal new file mode 100644 index 0000000..e69de29 diff --git a/engine/rules/fixtures/haskell/match/cabal/dist-newstyle/build/.keep b/engine/rules/fixtures/haskell/match/cabal/dist-newstyle/build/.keep new file mode 100644 index 0000000..e69de29 diff --git a/engine/rules/fixtures/haskell/match/cabal/expected.txt b/engine/rules/fixtures/haskell/match/cabal/expected.txt new file mode 100644 index 0000000..48a004c --- /dev/null +++ b/engine/rules/fixtures/haskell/match/cabal/expected.txt @@ -0,0 +1 @@ +dist-newstyle diff --git a/engine/rules/fixtures/haskell/match/cabal/src/Main.hs b/engine/rules/fixtures/haskell/match/cabal/src/Main.hs new file mode 100644 index 0000000..e69de29 diff --git a/engine/rules/fixtures/haskell/match/stack/.stack-work/dist/.keep b/engine/rules/fixtures/haskell/match/stack/.stack-work/dist/.keep new file mode 100644 index 0000000..e69de29 diff --git a/engine/rules/fixtures/haskell/match/stack/expected.txt b/engine/rules/fixtures/haskell/match/stack/expected.txt new file mode 100644 index 0000000..8ee1bf9 --- /dev/null +++ b/engine/rules/fixtures/haskell/match/stack/expected.txt @@ -0,0 +1 @@ +.stack-work diff --git a/engine/rules/fixtures/haskell/match/stack/package.yaml b/engine/rules/fixtures/haskell/match/stack/package.yaml new file mode 100644 index 0000000..e69de29 diff --git a/engine/rules/fixtures/haskell/match/stack/stack.yaml b/engine/rules/fixtures/haskell/match/stack/stack.yaml new file mode 100644 index 0000000..e69de29 diff --git a/engine/rules/fixtures/haskell/nomatch/no-project-file/.stack-work/.keep b/engine/rules/fixtures/haskell/nomatch/no-project-file/.stack-work/.keep new file mode 100644 index 0000000..e69de29 diff --git a/engine/rules/fixtures/haskell/nomatch/no-project-file/README.md b/engine/rules/fixtures/haskell/nomatch/no-project-file/README.md new file mode 100644 index 0000000..e69de29 diff --git a/engine/rules/fixtures/haskell/nomatch/no-project-file/dist-newstyle/.keep b/engine/rules/fixtures/haskell/nomatch/no-project-file/dist-newstyle/.keep new file mode 100644 index 0000000..e69de29 diff --git a/engine/rules/haskell.toml b/engine/rules/haskell.toml new file mode 100644 index 0000000..5a09830 --- /dev/null +++ b/engine/rules/haskell.toml @@ -0,0 +1,25 @@ +schema = 2 +id = "haskell" +name = "Haskell (Cabal and Stack)" + +# Cabal builds into dist-newstyle, and `cabal clean` "cleans up the +# temporary files and build artifacts stored in the dist-newstyle folder" +# (https://cabal.readthedocs.io/en/stable/cabal-commands.html). Stack's +# work-dir has "Default: .stack-work" and `stack clean --full` deletes it +# (https://docs.haskellstack.org/en/stable/configure/yaml/non-project/). +# Installed dependencies live in ~/.cabal and ~/.stack, not in the project. +[detect] +any_files = ["cabal.project", "stack.yaml"] +any_glob = ["*.cabal"] + +[[artifact]] +path = "dist-newstyle" +class = "safe" +reason = "Cabal build output. Recreated by the next cabal build." +restore = "cabal build" + +[[artifact]] +path = ".stack-work" +class = "safe" +reason = "Stack build output. Recreated by the next stack build." +restore = "stack build"