on d82d607 help sign in
ormolu/README.md
90 lines 2.5 kB history raw
1# Ormolu
3[![CircleCI](https://circleci.com/gh/tweag/ormolu/tree/master.svg?style=svg&circle-token=cfd37a39265561eb44e608f97cf953cb2a394c03)](https://circleci.com/gh/tweag/ormolu/tree/master)
5Ormolu is a formatter for Haskell source code. The project was created with
6the following features in mind:
8* Using GHC's own parser to avoid parsing problems caused by
9 [`haskell-src-exts`][haskell-src-exts].
10* Let some whitespace be programmable. The layout of the input
11 influence the layout choices in the output. This means that the
12 choices between single-line/multi-line layouts in each particular
13 situation are made by the user, not by an algorithm. This makes the
14 implementation simpler and leaves some control to the user while
15 still guaranteeing that the formatted code is stylistically
16 consistent.
17* Writing code in such a way so it's easy to modify and maintain. Roughly,
18 it means that the project follows the path of [`hindent`][hindent] and is
19 very much about printing AST in a particular way.
20* Implementing one “true” formatting style which admits no configuration.
21* That formatting style aims to result in minimal diffs while still
22 remaining very close to “conventional” Haskell formatting people use.
23* Idempotency: formatting already formatted code doesn't change it.
24* Be well-tested and robust to the point that it can be used in large
25 projects without exposing unfortunate, disappointing bugs here and there.
27## Building
29The easiest way to build the project is with Nix:
31```console
32$ nix-build
33```
35Or with `cabal-install` from the Nix shell:
37```console
38$ nix-shell --run "cabal new-build"
39```
41Alternatively, `stack` could be used with a `stack.yaml` file as follows.
43```console
44$ cat stack.yaml
45resolver: lts-13.19
46packages:
47- '.'
49$ stack build
50```
52## Usage
54The following will print the formatted output to the standard output.
56```console
57$ ormolu Module.hs
58```
60Add `--mode inplace` to replace the contents of the input file with the
61formatted output.
63```console
64$ ormolu --mode inplace Module.hs
65```
67A configuration file can specify the language extensions to use by default.
69```console
70$ cat ormolu.yaml
71ghc-opts:
72 - -XLambdaCase
73unsafe: False
74debug: False
76$ ormolu -c ormolu.yaml Module.hs
77```
79## Contributing
81See [CONTRIBUTING.md](./CONTRIBUTING.md).
83## License
85See [LICENSE.md](./LICENSE.md).
87Copyright © 2018–present Tweag I/O
89[haskell-src-exts]: https://hackage.haskell.org/package/haskell-src-exts
90[hindent]: https://hackage.haskell.org/package/hindent