Note
Mercury is migrating our backend build to Buck2 after outgrowing the Cabal build system. As a result, ghciwatch is currently in maintenance mode: we are not developing new features and code review bandwidth is limited.
For more information on Mercury's Buck2 migration, see some of the conference talks by our engineers and contractors:
- "Integrating Nix and Buck2 for fun and profit" by Claudio Bley (Tweag) at NixCon 2024 (31 minutes).
- "Remote Execution with Buck2 and Nix" by Claudio Bley (Tweag) at FOSDEM 2025 (20 minutes).
- "Haskell Builds at Scale: Comparing Bazel and Buck2" by Andreas Herrmann (Tweag) at BazelCon 2025 (32 minutes).
Ghciwatch loads a GHCi session for a Haskell project and reloads it when source files change.
- GHCi output is displayed to the user as soon as it's printed.
- Ghciwatch can handle new modules, removed modules, or moved modules without a hitch
- A variety of lifecycle hooks let you run Haskell code or shell commands on a variety of events.
- Run a test suite with
--test-ghci TestMain.testMain. - Refresh your
.cabalfiles withhpackbefore GHCi starts using--before-startup-shell hpack. - Format your code asynchronously using
--before-reload-shell async:fourmolu.
- Run a test suite with
- Custom globs can be supplied to reload or restart the GHCi session when non-Haskell files (like templates or database schema definitions) change.
- Ghciwatch can clear the screen between reloads.
- Compilation errors can be written to a file with
--error-file, for compatibility with ghcid's--outputfileoption. - Comments starting with
-- $>can be evaluated in GHCi.- Eval comments have access to the top-level bindings of the module they're defined in, including unexported bindings.
- Multi-line eval comments are supported with
{- $> ... <$ -}.
Check out a quick demo to see how ghciwatch feels in practice:
See CONTRIBUTING.md for information on hacking ghciwatch.