hindent for Mac
$ hindent --help hindent - Reformat Haskell source code
hindent — overview
Haskell pretty printer
Install
$ stack install hindent
Usage
$ hindent --help hindent - Reformat Haskell source code
Usage: hindent [--version | [--line-length ARG] [--indent-size ARG | --tab-size ARG] [--no-force-newline] [--sort-imports | --no-sort-imports] [--style STYLE] [-X GHCEXT] [--validate] [FILENAMES]]
Available options: --version Print the version --line-length ARG Desired length of lines (default: 80) --indent-size ARG Indentation size in spaces (default: 2) --tab-size ARG Same as --indent-size, for compatibility --no-force-newline Don't force a trailing newline --sort-imports Sort imports in groups --no-sort-imports Don't sort imports --style STYLE Style to print with (historical, now ignored) -X GHCEXT Language extension --validate Check if files are formatted without changing them -h,--help Show this help text
hindent is used in a pipeline style
$ cat path/to/sourcefile.hs | hindent
The default indentation size is 2 spaces. Configure indentation size with --indent-size:
$ echo 'example = case x of Just p -> foo bar' | hindent --indent-size 2; echo example = case x of Just p -> foo bar $ echo 'example = case x of Just p -> foo bar' | hindent --indent-size 4; echo example = case x of Just p -> foo bar
Customization
Create a .hindent.yaml file in your project directory or in your ~/ home directory. The following fields are accepted and are the default:
By default, hindent preserves the newline or lack of newline in your input. With force-trailing-newline, it will make sure there is always a trailing newline.
hindent can be forced to insert a newline before specific operators and tokens with line-breaks. This is especially useful when utilizing libraries like servant which use long type aliases.
Using extensions, hindent can be made aware of valid syntactic compiler extensions that would normally be considered invalid syntax.
It is also possible to specify which extensions HIndent runs with in your .hindent.yaml:
Emacs
In
there is hindent-mode, which provides keybindings to reindent parts of the buffer: M-q reformats the current declaration. When inside a comment, it fills the current paragraph instead, like the standard M-q. C-M- reformats the current region.
To enable it, add the following to your init file:
Vim
The 'formatprg' option lets you use an external program (like hindent) to format your text. Put the following line into ~/.vim/ftplugin/haskell.vim to set this option for Haskell files:
setlocal formatprg=hindent
Then you can format with hindent using gq. Read :help gq and help 'formatprg' for more details.
Note that unlike in emacs you have to take care of selecting a sensible buffer region as input to hindent yourself. If that is too much trouble you can try
which provides a text object for top level bindings.
In order to format an entire source file execute:
:%!hindent
Alternatively you could use the vim-hindent plugin which runs hindent automatically when a Haskell file is saved.
Details
Haskell 美化打印器
How to install hindent
- Open Terminal (press ⌘ + Space and type “Terminal”).
- If Homebrew is not installed yet, run the command below first.
- Run this command:
Latest 10 releases
Last updated 2026-01-24; current version v6.3.0, with the latest 10 releases listed.
| Version | Released | Type | Size | macOS | Windows | Linux |
|---|---|---|---|---|---|---|
| v6.3.0 | 2026-01-24 | Stable | 523 KB | Download | — | — |
| v6.2.1 | 2024-11-28 | Stable | 449 KB | — | — | — |
| v6.2.0 | 2024-09-07 | Stable | 456 KB | — | — | — |
| v6.1.1 | 2023-11-12 | Stable | 330 KB | — | — | — |
| v6.1.0 | 2023-05-17 | Stable | 328 KB | — | — | — |
| v6.0.0 | 2023-02-21 | Stable | 347 KB | — | — | — |
| v5.3.4 | 2022-07-07 | Stable | — | — | — | — |
| v5.3.3 | 2022-07-07 | Stable | — | — | — | — |
| v5.3.2 | 2021-02-01 | Stable | — | — | — | — |
| 5.2.5 | 2018-01-04 | Stable | — | — | Download | — |
Data from GitHub Releases; stable releases first, each group sorted newest first.
Prebuilt bottle platforms
Official Homebrew bottles cover:
- Apple silicon · latest macOS
- Apple silicon · macOS 26 Tahoe
- Apple silicon · macOS 15 Sequoia
- Apple silicon · macOS 14 Sonoma
- Intel · macOS 14 Sonoma
- Linux · ARM64
- Linux · x86_64
Compared with similar apps
Only public metadata is compared, with no subjective recommendation; see the compare pages for field-by-field comparisons.
| App | Version | License | Architecture | 30-day installs |
|---|---|---|---|---|
| hindent | v6.3.0 | BSD-3-Clause | CLI | 1 |
| miruo | 0.9.6b | GPL-3.0-only | CLI | 18 |
| stylish-haskell | v0.15.1.0 | BSD-3-Clause | CLI | 7 |
| ormolu | 0.9.0.0 | BSD-3-Clause | CLI | 6 |
Similar apps: Command-line Tools
miruo
$ tar zxvf miruo-x.y.z.tar.gz $ cd miruo-x.y.z $ ./configure $ make $ sudo make installstylish-haskell
A simple Haskell code prettifier. The goal is not to format all of the code in a file, since I…ormolu
Ormolu is a source code formatting tool for Haskell developers, used via the command line.hpack
hpack: A modern format for Haskell packagesopenssl@4
Cryptography and SSL/TLS Toolkitxz
General-purpose data compression with high compression ratioCategories: Command-line Tools