1

I had made a script for compiling my haskell programs (so far just simple scripts consisting in a single source file) that contained, before the call to ghc, the following lines:

echo "Running hlint"
hlint ${1}
echo "Running scan"
~/.cabal/bin/scan -j False ${1}
echo "Running doctest"
~/.cabal/bin/doctest ${1}

(${1} referring to the single .hs source file.)

How to get some equivalent checking done when using stack to manage and build my programs?

I would like to setup some global configuration that would have these commands run automatically on the source code when calling stack build in any of my projects.

bli
  • 7,549
  • 7
  • 48
  • 94

1 Answers1

2

Stack provides a --exec flag which allows you to do this. Check the 'Flags' documentation for a full example, but we can see a command like:

$ stack build --test --exec "echo Hi!"

Where --exec is the 'do other stuff' and --test runs the tests.

Related to your example, it could look like:

stack build \
  --exec "hlint foo" \
  --exec "~/.cabal/bin/scan -j False bar"
  --exec "~/.cabal/bin/doctest baz"