The hindent package

[Tags:benchmark, bsd3, library, program, test]

Extensible Haskell pretty printer. Both a library and an executable.

See the Github page for usage/explanation:

[Skip to Readme]


Versions 0.0, 1.0, 2.0, 2.1, 2.2, 2.3, 2.4, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.9.1, 4.0, 4.1.0, 4.1.1, 4.2.0, 4.2.1, 4.2.2, 4.2.3, 4.2.4, 4.3.0, 4.3.1, 4.3.2, 4.3.3, 4.3.4, 4.3.5, 4.3.6, 4.3.7, 4.3.8, 4.3.9, 4.3.10, 4.3.11, 4.3.12, 4.4.0, 4.4.1, 4.4.2, 4.5.0, 4.5.1, 4.5.2, 4.5.3, 4.5.4, 4.5.5, 4.5.6, 4.5.7, 4.6.0, 4.6.1, 4.6.2, 4.6.3, 4.6.4, 5.0.0, 5.0.1, 5.1.0, 5.1.1, 5.2.0, 5.2.1, 5.2.2, 5.2.3
Change log
Dependencies base (>=4.7 && <5), bytestring, containers, deepseq, descriptive (>=0.7 && <0.10), directory, exceptions, ghc-prim, haskell-src-exts (>=1.18), hindent, monad-loops, mtl, path, path-io, text, transformers, unix-compat, utf8-string, yaml [details]
License BSD3
Copyright 2014 Chris Done, 2015 Andrew Gibiansky
Author Chris Done, Andrew Gibiansky, Tobias Pflug, Pierre Radermecker
Category Development
Home page
Bug tracker
Source repository head: git clone
Uploaded Sun May 7 16:44:38 UTC 2017 by sighingnow
Distributions Arch:5.2.3, LTSHaskell:5.2.3, NixOS:5.2.3, Stackage:5.2.3, Tumbleweed:5.2.3
Downloads 11049 total (308 in the last 30 days)
0 []
Status Docs available [build log]
Last success reported on 2017-05-07 [all 1 reports]
Hackage Matrix CI




Maintainer's Corner

For package maintainers and hackage trustees

Readme for hindent

Readme for hindent-5.2.3

hindent Hackage Build Status

Haskell pretty printer

Demonstration site



$ stack install hindent


$ hindent --help
hindent --version --help --style STYLE --line-length <...> --indent-size <...> --no-force-newline [-X<...>]* [<FILENAME>]
Version 5.1.1
Default --indent-size is 2. Specify --indent-size 4 if you prefer that.
-X to pass extensions e.g. -XMagicHash etc.
The --style option is now ignored, but preserved for backwards-compatibility.
Johan Tibell is the default and only style.

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


Create a .hindent.yaml file in your project directory or in your ~/ home directory. The following fields are accepted and are the default:

indent-size: 2
line-length: 80
force-trailing-newline: true

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.


In elisp/hindent.el 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:

(add-to-list 'load-path "/path/to/hindent/elisp")
(require 'hindent)
(add-hook 'haskell-mode-hook #'hindent-mode)


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 vim-textobj-haskell which provides a text object for top level bindings.

In order to format an entire source file execute:


Alternatively you could use the vim-hindent plugin which runs hindent automatically when a Haskell file is saved.


Fortunately, you can use with the path to hindent specified instead of that to stylish-haskell. Works like a charm that way!