hlint
Suggest improvements for Haskell code
TLDR
Display suggestions for a given file
Check all Haskell files and generate a report
Automatically apply most suggestions
Display additional options
Generate a settings file ignoring all outstanding hints
SYNOPSIS
hlint [OPTION...] [FILE|DIR]...
PARAMETERS
-h, --help
Display help message and exit
-i, --ignore=NOTE
Ignore suggestions matching the given note(s)
--hint=FILE
Load hints from the given file(s), can be repeated
-j, --threads=N
Set the number of threads to use (default: auto-detect)
--json
Output results in JSON format for tooling integration
-r, --refactor
Enable refactoring mode, printing replacement hints
-x, --refactor-hint=NOTE
Refactor only hints matching NOTE
--test
Run in test mode, checking if hints apply correctly
-c, --color=YES|NO|AUTO
Control colored output (default: AUTO)
--cpp-include=FILE
Include FILE before parsing for CPP preprocessing
-p, --parallel
Deprecated alias for --threads (use auto)
--report
Generate HTML report file
-q, --quiet
Suppress non-error output
--find=QUERY
Suggest hints matching the query
--no-exit-code
Always exit with code 0, even if suggestions found
DESCRIPTION
HLint is a powerful command-line tool designed specifically for Haskell programmers. It analyzes Haskell source code files or entire directories, identifying opportunities for improvement such as simplifying expressions, replacing verbose code with more idiomatic alternatives, fixing style issues, and suggesting performance enhancements.
Unlike rigid linters, HLint provides suggestions rather than errors, allowing developers to focus on code quality without disrupting workflow. It uses a flexible hint system where rules are defined in external files, enabling customization for project-specific needs or team conventions. Hints cover common patterns like using map instead of explicit list comprehensions, avoiding unnecessary seq, or preferring foldl' over foldl.
HLint supports parallel processing for large codebases, JSON output for integration with editors like Vim or VS Code via plugins, and refactoring modes to automatically apply changes. It's an essential tool in the Haskell ecosystem, often run in CI pipelines or pre-commit hooks to maintain high code standards. Written in Haskell itself, it's efficient and extensible.
CAVEATS
Requires a Haskell environment (GHC); install via cabal install hlint or stack install hlint. Only works on Haskell source code (.hs, .lhs files). May produce false positives on highly custom code.
EDITOR INTEGRATION
Plugins available for Vim (vim-hlint), Emacs (flycheck-hlint), VS Code (haskell extension). Run hlint --json for piping into tools.
CUSTOM HINTS
Create .hlint.yaml in project root for local rules. Example: ignore: {name: "Use foo"} to suppress specific hints.
HISTORY
Developed by Neil Mitchell starting in 2006. Actively maintained as part of the Haskell toolchain, with regular releases via Hackage. Evolved from simple style checker to full-featured suggester with JSON/parallel support in recent versions.


