hlint

tool for suggesting improvements to Haskell source code

TLDR

Display suggestions for a Haskell file
$ hlint [path/to/file.hs]
Check all Haskell files and generate a report
$ hlint [path/to/directory] -r
Automatically apply most suggestions
$ hlint [path/to/file.hs] --refactor
Display additional refactor options
$ hlint [path/to/file.hs] --refactor-options
Generate a settings file ignoring all current hints
$ hlint [path/to/file.hs] --default > .hlint.yaml
Run using all available processors
$ hlint [path/to/directory] -j
Ignore a specific hint
$ hlint [path/to/file.hs] --ignore="Use camelCase"
Output suggestions as JSON
$ hlint [path/to/file.hs] --json

SYNOPSIS

hlint [options] [files]

DESCRIPTION

hlint is a tool for suggesting improvements to Haskell source code. It analyzes code and provides suggestions for simplification, redundancy removal, and style improvements based on common Haskell idioms.Suggestions include simplifying expressions, removing unnecessary extensions, applying standard library functions, and following best practices. The tool can automatically apply many of its suggestions through the refactor mode.Configuration files (.hlint.yaml) allow customizing which hints to apply or ignore on a per-project basis.

PARAMETERS

-r, --report[=FILE]

Generate an HTML report of suggestions (default: report.html)
--refactor
Automatically apply suggestions, using the `refactor` tool from apply-refact
--refactor-options OPTIONS
Pass extra options to the `refactor` executable
-d, --default
Print a default .hlint.yaml, ignoring all hints currently triggered, to stdout
-h, --hint FILE
Use hints from the specified file
-i, --ignore HINT
Ignore a specific hint
-s, --show
Show all hints, including those normally skipped
-j[N], --threads[=N]
Run on N processors (default: 1; -j alone uses all physical cores)
-c, --colour, --color[=always|never|auto]
Control colored output
--json
Output hint data as JSON
--sarif
Output hint data as SARIF
-f, --find FILE
Search a Haskell file for patterns to turn into new hints
-X EXTENSION, --language EXTENSION
Enable or disable a GHC language extension (e.g. -XNoCPP)
--cpp-define NAME[=VALUE], --cpp-include DIR
Configure the cpphs C preprocessor run over input files

INSTALL

sudo apt install hlint
sudo dnf install hlint
sudo pacman -S hlint
sudo apk add hlint
sudo zypper install hlint
brew install hlint
nix profile install nixpkgs#hlint

CAVEATS

Not all suggestions are appropriate for every codebase. Some hints may conflict with specific coding standards or performance requirements. Always review automated refactoring changes before committing.

HISTORY

hlint was created by Neil Mitchell and first released around 2006. It has become a standard tool in the Haskell ecosystem for maintaining code quality and is commonly integrated into CI pipelines and editor plugins.

SEE ALSO

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

RESOURCES

Source code · Documentation