my question in short is "how to get a fast save-retest workflow in a cabal-managed multi-library haskell project repository?"
I already tried a few things and did some research. Before getting into more details please have a look at the typical project repo structure and then have the question broken down into more details:
Repository Development Structure
i work on multiple Haskell projects that usually have the following form:
.
├── foo
│ ├── foo.cabal
│ ├── src
│ ├── unit-test
│ └── ...
├── bar
│ ├── bar.cabal
│ ├── src
│ ├── unit-test
│ └── ...
├── baz
│ ├── baz.cabal
│ ├── src
│ ├── unit-test
│ └── ...
├── stack.yaml
├── cabal.project
├── nix
│ └── ...
└── ...
The cabal.project
file looks like this:
packages:
foo
bar
baz
...
tests: True
run-tests: True
The stack file contains basically the same project list and an LTS ID, so i can just just the stackProject
nix function from IOHK's haskell.nix to provide myself a nix shell which has cabal etc. in place. (This question is more about cabal handling so i consider this text paragraph here only a background note that i think is not relevant for this stack overflow question.)
This setup allows me to just run cabal test all
anywhere in the project, which is great. This is my simple method to see if i broke anything before closing the next git commit.
Rapid Save-Retest Workflow
Before i got to nix, i used stack build/test --watch
which was nice, because i could now have a shell open which always retests and rebuilds the whole project after i changed anything anywhere.
This can be simulated with inotify
:
while true; do
inotifywait -e modify -r ./;
cabal test all
done
This is not really fast but it also does the job.
After i got to know about GHCID i was amazed by how blazingly fast it is.
It is also easy to use with cabal repl
.
Unfortunately (this problem was also mentioned but left unanswered in a comment here How to run test suite in ghcid with cabal?), GHCID can be run on one specific unit test suite and will not detect changes on the library that the unit tests are supposed to check. (Putting all the library modules into the unit test description in the cabal file is something that i consider an ugly hack and i woul rather like to avoid that)
Also, it seems i can't run GHCID on the whole repository like cabal test all
or stack test --watch
do.
The extreme speed of GHCID is something that i really want in my workflow.
cabal
is a tool that has existed long time before stack, how do people work on their multi-lib repositories to have a fast overview of all the test cases they broke after they edited multiple files in multiple libs? If the GHCID way does not work well, what is the way to do it?
cabal test all
to its terminal window whenever I want to check. Turns out I'm working more efficient when not relying on anything to happen automatically at all – that just keeps me waiting for the tab completion to come along or whatever, and the unpredictability means I'm not getting the best out of the editor commands themselves. – Sarinasarine.ghci
file or a dummy library that combines all of them (including the test suite). – Colour