-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #2043 # Local usage notes I suspect that HLS in VS Code spontaneously pollutes the `.hie` directory, because after a few successful invocations, `weeder` started complaining with: ``` incompatible hie file: /home/kostmo/github/swarm/.hie/Swarm/Web/Auth.hie this version of weeder was compiled with GHC version 9064 the hie files in this project were generated with GHC version 9048 weeder must be built with the same GHC version as the project it is used on ``` ## Fixing false positives Previously, for each `library` and `executable`, the HIE directory was always the same: ``` ghc-options: -hiedir=.hie ``` However, most of the executables have at least one module path that is the same relative to their `hs-source-dirs` base: namely, `Main.hs`. This resulted in all but one of the `Main.hie` files being overwritten in the end. To avoid this, I have specified a different `-hiedir` for each `library`/`executable`/`test` that parallels its `hs-source-dirs` base. This way, so long as `hs-source-dirs` are unique across these targets, all of the `*.hs` files across the entire project will have unique `*.hie` paths. ## Whitelisting exceptions There are some known limitations with `weeder` regarding support for Template Haskell and type families. Exceptions are specified in the `roots` list in `weeder.toml`. After removing a handful of dead functions myself, there are approx. 30 "true positive" weeds that I have listed explicitly in `weeder.toml`. Maintenance of this list of exceptions should eventually be easier with ocharles/weeder#146. # Integration with CI I found a ready-made GitHub Action for weeder: https://github.com/freckle/weeder-action I hacked support directly into the generated `.github/workflows/haskell-ci.yml` file. Ideally, the generator would have an option for a `weeder` step. Indeed, there is an open issue for supporting `weeder` in `haskell-ci`: haskell-CI/haskell-ci#132 A separate but related functionality that would be nice in `haskell-ci` is to specify **one** of the GHC versions in the matrix to do additional validations/builds that would be redundant if performed on the other matrix entries. I suppose `weeder` is inexpensive enough to redo four times, but the `weeder` binary is not available for download for all GHC versions (e.g. ghc `9.8.2`). Something like `haddock` we probably only need to build once. I have hacked this in to the generated file for `weeder` with a simple [`if` condition](https://github.com/swarm-game/swarm/pull/2044/files#diff-73f8a010e9b95aa9fe944c316576b12c2ec961272d428e38721112ecb1c1a98bR227).
- Loading branch information
Showing
10 changed files
with
145 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
File renamed without changes.
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash -ex | ||
|
||
cd $(git rev-parse --show-toplevel) | ||
|
||
# First, install Weeder: | ||
# cabal install weeder | ||
|
||
cabal clean | ||
cabal build -O0 -j all | ||
|
||
weeder -N |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
roots = [ | ||
"^Main.main$", | ||
"^Paths_.*", | ||
|
||
# Workarounds for TH parsing: | ||
# ------------------------------- | ||
"^Swarm.Language.Pipeline.QQ.tmQ$", | ||
"^Swarm.Language.Parser.QQ.tyQ$", | ||
"^Swarm.Util.Lens.makeLensesNoSigs$", | ||
"^Swarm.Util.Lens.makeLensesExcluding$", | ||
|
||
# Workarounds for type families: | ||
# ------------------------------- | ||
"^Swarm.Game.World.Compile.NoFunParams$", | ||
|
||
# True positives: | ||
# ===================================== | ||
"^Main.prop_hittingSetMinimal$", | ||
"^Main.printAllLogs$", | ||
"^Control.Carrier.Accum.FixedStrict.execAccum$", | ||
"^Swarm.App.demoWeb$", | ||
"^Swarm.Effect.Unify.Common.dom$", | ||
"^Swarm.Effect.Unify.Fast.@@$", | ||
"^Swarm.Effect.Unify.Naive.runUnification$", | ||
"^Swarm.Game.Entity.entityNameFor$", | ||
"^Swarm.Game.Entity.singleton$", | ||
"^Swarm.Game.Entity.Cosmetic.getBackground$", | ||
"^Swarm.Game.Step.traceLogShow$", | ||
"^Swarm.Game.World.Compile.compile$", | ||
"^Swarm.Game.World.Compile.runCTerm$", | ||
"^Swarm.Game.World.lookupTerrainM$", | ||
"^Swarm.Language.Context.withBindings$", | ||
"^Swarm.Language.Context.singleton$", | ||
"^Swarm.Language.Parser.Util.showShortError$", | ||
"^Swarm.Language.Pipeline.extractTCtx$", | ||
"^Swarm.Language.Pretty.Prec$", | ||
"^Swarm.Language.Pretty.appliedTermPrec$", | ||
"^Swarm.Language.Requirements.Type.insert$", | ||
"^Swarm.Language.Syntax.Pattern.UTerm$", | ||
"^Swarm.Language.Syntax.Util.asTree$", | ||
"^Swarm.Language.Syntax.Util.mapFreeS$", | ||
"^Swarm.Util.replaceLast$", | ||
"^Swarm.Util.reflow$", | ||
"^Swarm.Util.isSuccessOr$", | ||
"^Swarm.Util._NonEmpty$", | ||
|
||
# True positives (unused lenses): | ||
# ------------------------------- | ||
"^Swarm.Language.Typed.polytype$", | ||
"^Swarm.Language.Typed.requires$", | ||
"^Swarm.Language.Typed.value$", | ||
"^Swarm.Language.Value.emptyEnv$", | ||
"^Swarm.Game.Scenario.staticPlacements$", | ||
"^Swarm.Game.Scenario.structureDefs$", | ||
"^Swarm.Game.Scenario.Scoring.Best.scenarioBestByAstSize$", | ||
"^Swarm.Game.Scenario.Scoring.Best.scenarioBestByCharCount$", | ||
"^Swarm.Game.Scenario.Scoring.Best.scenarioBestByTicks$", | ||
"^Swarm.Game.Scenario.Scoring.Best.scenarioBestByTime$", | ||
"^Swarm.Game.ScenarioInfo._NotStarted$", | ||
"^Swarm.Game.ScenarioInfo._Played$", | ||
"^Swarm.Game.State.Robot._VCLocation$", | ||
"^Swarm.Game.State.Robot._VCRobot$", | ||
"^Swarm.Game.State.Substate._NoWinCondition$", | ||
"^Swarm.Game.State.Substate._WinConditions$", | ||
] | ||
|
||
type-class-roots = true | ||
unused-types = true | ||
|