LinuxCommandLibrary

ghcid

Interactive Haskell development and testing

TLDR

Start ghcid and monitor a Haskell file for changes

$ ghcid [path/to/Main.hs]
copy

Start ghcid with a specific command, such as loading a Stack or Cabal project
$ ghcid --command "[stack ghci Main.hs]"
copy

Run an action (default main) on each file save
$ ghcid --run=[action] [path/to/Main.hs]
copy

Set maximum height and width (default to console height and width)
$ ghcid --height=[height] --width=[width] [path/to/Main.hs]
copy

Write full GHC compiler output to a file
$ ghcid --outputfile=[path/to/output_file.txt] [path/to/Main.hs]
copy

Execute REPL commands (eg. -- $> 1+1) on each file save
$ ghcid --allow-eval [path/to/Main.hs]
copy

SYNOPSIS

ghcid [options] [target]

PARAMETERS

--command=CMD
    Command to run after successful compilation. This overrides the default command.

--test=CMD
    Sets CMD to be used instead of the default test program.

--recompile
    Force recompilation on startup.

--warnings
    Show warnings.

--no-warnings
    Hide warnings (default).

--quiet
    Run quietly, hiding most output.

--verbose
    Be verbose, showing lots of output.

--version
    Show version information and exit.

--help
    Show help message and exit.

target
    The target file to load (e.g., a Main.hs file).

DESCRIPTION

ghcid is an interactive compiler designed to make Haskell development faster and more pleasant. It automatically reloads and type-checks your Haskell code whenever you make changes, providing immediate feedback on errors. This allows for a tight feedback loop, encouraging experimentation and rapid iteration. It works by monitoring your source files and recompiling them automatically when it detects a change. ghcid simplifies the development workflow by eliminating the need to manually recompile and test code after each modification. ghcid is particularly useful for interactive development sessions, where you want to quickly experiment with different code snippets and see the results immediately. It aims to be a tool that facilitates faster and better Haskell code production. It reduces the friction involved in compilation and error finding.

CAVEATS

ghcid relies on the Haskell compiler (GHC) being installed and configured correctly. It might require adjustments to your Cabal/Stack configuration for optimal use. Multi-threaded builds and certain GHC extensions may require specific configurations for ghcid to function correctly.

STARTUP

When ghcid starts, it compiles the target file. If compilation is successful, it executes the command defined by the --command or --test flags, or defaults to a basic command. If compilation fails, ghcid displays the error messages in the terminal.

AUTOMATIC RELOADING

Whenever a source file changes, ghcid automatically recompiles the target file. If successful, the command is re-executed, allowing developers to see the immediate results of their changes.

HISTORY

ghcid was created by Neil Mitchell to streamline Haskell development by automating recompilation and providing quick feedback.
It has been used in many Haskell projects and is regarded as a helpful tool for interactive development.

SEE ALSO

ghc(1), cabal(1), stack(1)

Copied to clipboard