I assume that the intent is that the package.yaml is the definitive package description. If that is the case, you can specify that the package.yaml should always prevail, with Stack’s --hpack-force flag.
- name: Compare the expected and actual dist directories
run: |
if [ "$(git diff --ignore-space-at-eol ${{inputs.dist-path}} | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after the build. See the status below:"
git diff
exit 1
fi
id: diff
# Check this before building, otherwise stack will overwrite the cabal file.
- name: Validate cabal file is properly generated from HPack
if: matrix.os != 'windows-latest' # Since we're using `diff -u`, cannot run on Windows
run: |
mv hindent.cabal hindent.cabal.original
# See https://github.com/commercialhaskell/stack/issues/3697#issuecomment-353729540.
stack build --resolver=${{ matrix.resolver }} --dry-run
diff -u hindent.cabal.original hindent.cabal
This is such a minor inconvenience that I remain absolutely baffled that Haskellers, who spend an hour debugging type level errors, would buy into such a solution that causes so many problems just so they can avoid editing a cabal file for ~15 seconds.
Having 100s (or 1000s!) of explicitly-listed modules makes the cabal file annoying to read & work with.
It’s not a killer (I rarely use package.yaml for my own projects) but it is a pain in the butt.
Tbh, I think writing .cabal directly is kind of folly though. I’d probably compile from a Nix expression instead if metaprogramming in yaml or cabal directly.
When I’m working on a new project it is a huge inconvenience. I’m reorganizing a lot and it’s amazing to just have a tool that manages the module changes.