问题
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?
回答1:
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.
回答2:
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.
回答3:
The ghcid project provides something limited to ~ :reload
. It provides a few extra features (format to a fixed number of lines, persist warnings from previously loaded files), but not the generality of running any command.
来源:https://stackoverflow.com/questions/6323150/sbt-like-features-in-the-haskell-build-ecosystem