Use filewatcher to have ghc continually compiling

March 21, 2016

Posted in: haskell, ghc, development, workflow.

1 Automatically retry stack build

When working on a Haskell project, I find is useful to continually attempt to recompile my code. To have this happen automatically, open up a shell window or buffer and run:

filewatcher --restart "src/*.hs pathway-parse.cabal" "stack build"

filewatcher watches a directory tree and runs a command when matching files within the tree change. The command above says to watch the src directory and the .cabal file and if there are any changes, run stack build. The --restart flag says that if a change is detected while the command is running (based on a reaction to a previous change), the running command will be stopped. This is useful as builds can take a long time.

2 In general

filewatcher --restart "src/*.hs pathway-parse.cabal" "make"

Then, use your Makefile for things like running Pandoc, latex, or any other Makefile.

Comments