In Rust, there is the immensely useful “cargo check” command, which typechecks the whole codebase. It just works. I expect any command like that to be even more useful in Haskell, since we use a lot of type level stuff in Haskell!
But I can’t seem to make it work for cabal in any nontrivial way. Sometimes you see a recommendation of cabal build --ghc-options="-fno-code", and this may work for small, simple, single cabal packages. But it doesn’t work, it seems, already for cabal projects with more than one package. I doubt it would work for template haskell.
This seems like a huge omission in Haskell’s tooling landscape. Has anyone managed to fill in this gap, maybe with a hack? Or is there any work in progress towards something like this? I couldn’t find anything so far.
Can you easily include either ghcid or HLS into a script? For example, I’d really like to do something like git rebase --exec "cabal typecheck to make sure every commit typechecks. I don’t know of a way to do this with ghcid or HLS.
I hadn’t noticed this until now, but you’re right that --ghc-options=-fno-code appears not to work with cabal build (/usr/bin/ar: dist-newstyle/build/x86_64-linux/ghc-9.10.1/hello-hs-0.1.0.0/build/Lib.o: No such file or directory). But it does work with cabal repl, and indeed this is utilised by ghcid. So, unless you’re interested in improving things upstream, you could hack something together by piping commands in to that.