3[](http://opensource.org/licenses/BSD-3-Clause)
4[](https://hackage.haskell.org/package/ormolu)
5[](http://stackage.org/nightly/package/ormolu)
6[](http://stackage.org/lts/package/ormolu)
7[](https://circleci.com/gh/tweag/ormolu/tree/master)
9Ormolu is a formatter for Haskell source code. The project was created with
10the following goals in mind:
12* Using GHC's own parser to avoid parsing problems caused by
13 [`haskell-src-exts`][haskell-src-exts].
14* Let some whitespace be programmable. The layout of the input influences
15 the layout choices in the output. This means that the choices between
16 single-line/multi-line layouts in each particular situation are made by
17 the user, not by an algorithm. This makes the implementation simpler and
18 leaves some control to the user while still guaranteeing that the
19 formatted code is stylistically consistent.
20* Writing code in such a way so it's easy to modify and maintain.
21* Implementing one “true” formatting style which admits no configuration.
22* That formatting style aims to result in minimal diffs while still
23 remaining very close to “conventional” Haskell formatting people use.
24* Choose a style compatible with modern dialects of Haskell. As new Haskell
25 extensions enter broad use, we may change the style to accomodate them.
26* Idempotence: formatting already formatted code doesn't change it.
27* Be well-tested and robust to the point that it can be used in large
28 projects without exposing unfortunate, disappointing bugs here and there.
32The easiest way to build the project is with Nix:
38Or with `cabal-install` from the Nix shell:
41$ nix-shell --run "cabal new-build"
44Alternatively, `stack` could be used with a `stack.yaml` file as follows.
55To use Ormolu directly from GitHub with Nix, this snippet may come in handy:
58# This overlay adds Ormolu straight from GitHub.
61let source = super.fetchFromGitHub {
64 rev = "de279d80122b287374d4ed87c7b630db1f157642"; # update as necessary
65 sha256 = "0qrxfk62ww6b60ha9sqcgl4nb2n5fhf66a65wszjngwkybwlzmrv"; # as well
67 ormolu = import source { pkgs = self; };
69 haskell = super.haskell // {
70 packages = super.haskell.packages // {
71 "${ormolu.ormoluCompiler}" = super.haskell.packages.${ormolu.ormoluCompiler}.override {
72 overrides = ormolu.ormoluOverlay;
81The following will print the formatted output to the standard output.
87Add `--mode inplace` to replace the contents of the input file with the
91$ ormolu --mode inplace Module.hs
96* Does not handle CPP (wontfix, see [the design document][design]).
97* Input modules should be parsable by Haddock, which is a bit stricter
98 criterion than just being valid Haskell modules.
99* Various minor idempotence issues, most of them are related to comments.
103We know of the following editor integrations:
105* [Emacs][emacs-package]
106* [VS Code][vs-code-plugin]
110It's possible to try Ormolu on arbitrary packages from Hackage. For that
111execute (from the root of the cloned repo):
114$ nix-build -A hackage.<package>
117Then inspect `result/log.txt` for possible problems. The derivation will
118also contain formatted `.hs` files for inspection and original inputs with
119`.hs-original` extension (those are with CPP dropped, exactly what is fed
124See [CONTRIBUTING.md][contributing].
128See [LICENSE.md][license].
130Copyright © 2018–present Tweag I/O
132[design]: https://github.com/tweag/ormolu/blob/master/DESIGN.md#cpp
133[contributing]: https://github.com/tweag/ormolu/blob/master/CONTRIBUTING.md
134[license]: https://github.com/tweag/ormolu/blob/master/LICENSE.md
135[haskell-src-exts]: https://hackage.haskell.org/package/haskell-src-exts
136[emacs-package]: https://github.com/vyorkin/ormolu.el
137[vs-code-plugin]: https://marketplace.visualstudio.com/items?itemName=sjurmillidahl.ormolu-vscode
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list