When developing a Haskell package which will end up on Hackage, you need to have a strategy for testing your source distribution. This is the actual .tar.gz file that end users will receive when they run a Cabal/Stack install.
I wanted something that relied on Stack and would fit nicely into a Makefile. Here's what I came up with:
sdist: stack sdist DIST_DIR:=$$(stack path --dist-dir) SDIST_TAR:=$$(find $(DIST_DIR) -name "*.tar.gz" | tail -1) untar-sdist: sdist tar xzf $(SDIST_TAR) SDIST_FOLDER:=$$(basename $(SDIST_TAR) .tar.gz) INIT:=$$(stack init --force) TEST:=$$(stack build --test --haddock --no-haddock-deps) test_sdist: untar-sdist cd $(SDIST_FOLDER) && $(INIT) && $(TEST)
Running 'make test_sdist' will create a source distribution, untar the files, build the project as well as the haddock documentation and run the tests.