ghcid
Interactive Haskell development and testing
TLDR
Start ghcid and monitor a Haskell file for changes
Start ghcid with a specific command, such as loading a Stack or Cabal project
Run an action (default main) on each file save
Set maximum height and width (default to console height and width)
Write full GHC compiler output to a file
Execute REPL commands (eg. -- $> 1+1) on each file save
SYNOPSIS
ghcid [OPTIONS] [TARGET]
PARAMETERS
-c, --command COMMAND
Command to run (default: ghci)
-a, --arguments ARGUMENTS
Arguments to pass to the command
--ghci-arg ARG
Argument to ghci (deprecated, use --arguments)
--ghci-args ARGUMENTS
Arguments to ghci (deprecated, use --arguments)
-r, --reload RELOAD
File(s)/dir to reload on (default: all project files)
-l, --lint
Lint code with hlint
-W, --warnings
Display compiler warnings
-E, --exit-on-error
Exit on first error
--clear
Clear screen between tests
--rerun-timings
Print timing info for rerun tests
--top
Run from project top-level
-o, --output OUTPUT
Test output expression
-O, --outputfile OUTPUTFILE
Output file (deprecated, use --output)
--ignore IGNORE
Directories to ignore when watching
-T, --no-title
Suppress banner/title
--future
Assume future GHC version
-v, --verbose
Verbose output
--list-files
List watched files
-h, --help
Show help
--version
Print version
DESCRIPTION
Ghcid is a lightweight, fast development tool for Haskell projects that launches GHCi and automatically reloads and retests code upon file changes. It monitors specified files or directories, recompiling and running tests in a continuous loop, providing immediate feedback during development.
Ideal for TDD workflows, ghcid supports custom commands (default: ghci), test expressions, linting with hlint, and warning display. It clears the screen between runs for clarity and handles errors by exiting or continuing based on flags. Target can be a .cabal, package.yaml, .hs file, or directory.
By avoiding full rebuilds, it achieves sub-second reload times, boosting productivity. Verbose mode aids debugging, and ignore patterns exclude irrelevant files like .git. Widely used in Haskell ecosystem for its simplicity and speed.
CAVEATS
Requires GHC and Haskell project setup; high CPU on large projects with many files; no native Windows support (use WSL); reloads may fail on syntax errors until fixed.
INSTALLATION
Via cabal: cabal update && cabal install ghcid
Via stack: stack install ghcid
Or from Hackage/Nixpkgs.
CONFIGURATION
Uses .ghcid file in project root for default flags, e.g., --command='stack ghci'.
TARGETS
Defaults to .cabal/package.yaml if present; otherwise scans for .hs files.
HISTORY
Created by Will Yager in 2014 to address slow GHCi reloads. Maintained by Nam P. Nguyen since 2020. Reached v9.1.4 in 2023, integrating with modern tools like HLS and Nix.


