Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SBT-like features in the Haskell build ecosystem

I've been using Scala with SBT quite a bit lately. The REPL loop of has a handy feature: ~ COMMAND, meaning perform COMMAND for every source file change in the project. For instance:

~ test

and

~ compile

are terrifically useful for rapid development. I wonder, does anyone know of something similar for Haskell, a cabal shell, maybe?

like image 803
troutwine Avatar asked Dec 05 '22 21:12

troutwine


2 Answers

You can get something like this very easily using inotifywait.

Just fire up a terminal in your project directory and run something like this:

$ while inotifywait -qq -r -e modify .; do cabal build && ./dist/build/tests/tests; done

This also works for any other language; just insert the build commands of your choice.

like image 84
hammar Avatar answered Dec 21 '22 01:12

hammar


You can script ghci to both define your own commands, and augment existing commands. To do this:

  • define a ~/.ghci file
  • write a macro using :def to replace e.g. :reload

More info on GHCi :def commands is here.

like image 36
Don Stewart Avatar answered Dec 21 '22 02:12

Don Stewart