on master help sign in
Update the readme file

[skip ci]

commit0b7d784cd61b96079558adde1cacee05b598abaf authormrkkrp <mark.karpov@tweag.io> dateFri 10 May 2019, 16:36 (7 years ago) parent759c2c6
1 file changed+83−1
README.md+83−1
README.md+83−1
@@ -2,8 +2,90 @@
22
33[![CircleCI](https://circleci.com/gh/tweag/ormolu/tree/master.svg?style=svg&circle-token=cfd37a39265561eb44e608f97cf953cb2a394c03)](https://circleci.com/gh/tweag/ormolu/tree/master)
44
5−Ormolu is a formatter for Haskell source code.
5+Ormolu is a formatter for Haskell source code. The projects was created with
6+the following features in mind:
7+
8+* Using GHC's own parser to avoid parsing problems caused by
9+ [`haskell-src-exts`][haskell-src-exts].
10+* Writing code is such a way so it's easy to modify and maintain. Roughly,
11+ it means that the project follows the path of [`hindent`][hindent] and is
12+ very much about printing AST in a particular way.
13+* Implementing one “true” formatting style which admits no configuration.
14+* Let layout of input source code control layout choices in output. This
15+ means that the choices between single-line/multi-line layouts in each
16+ particular situation are made by user, not by an algorithm. This makes the
17+ implementation simpler and leaves just enough control to the user while
18+ still guaranteeing that the formatted code is stylistically consistent.
19+* Idempotency: formatting already formatted code doesn't change it.
20+* Be well-tested and robust to the point that it can be used in large
21+ projects without exposing unfortunate, disappointing bugs here and there.
22+* The project is commercially backed by a company, that is, Tweag. This
23+ guarantees that it'll be actively maintained and bugs will be fixed.
24+
25+## Contribution
26+
27+Issues (bugs, feature requests or otherwise feedback) may be reported in
28+[the GitHub issue tracker for this
29+project](https://github.com/tweag/ormolu/issues). Pull requests are also
30+welcome.
31+
32+### What to hack on?
33+
34+Right now there are two options for people who want to contribute:
35+
36+* Implementing rendering of AST. This is the main focus right now because we
37+ want to have a MVP which can render all syntactical constructions found in
38+ Haskell source code. Once that is achieved we'll polish the tool
39+ iteratively.
40+* [Fixing bugs][bugs]. If this seems more interesting than implementing
41+ rendering of AST, you are welcome to do this as well.
42+
43+### Implementing rendering of AST
44+
45+The `Ormolu.Printer.Combinators` module provides a DSL for rendering of GHC
46+AST. You'll probably only need this one module for writing new rendering
47+functions. The module documents how to use the printing combinators it
48+provides, consult the Haddocks to learn more about that.
49+
50+Create new modules corresponding to the things you want to render under
51+`Ormolu.Printer.Meat`. For example, there are `Ormolu.Printer.Meat.Type` and
52+`Ormolu.Printer.Meat.Declaration.Data`.
53+
54+Concrete rendering functions get their names by appending `p_` to record
55+field name which contains the part of AST of interest. For example, types
56+are often found in fields named `hsType`, so the function for rendering
57+types is correspondingly:
58+
59+```haskell
60+p_hsType :: HsType GhcPs -> R ()
61+```
62+
63+In general rendering functions like this take 1 or more arguments and
64+produce `R ()` which is a rendering action.
65+
66+### Testing
67+
68+Testing has been taken good care of and now it amounts to just adding
69+examples under `data/examples`. Each example is a pair of files:
70+`<example-name>.hs` for input and `<example-name>-out.hs` for corresponding
71+expected output.
72+
73+Testing is performed as following:
74+
75+* Given snippet of source code is parsed and pretty-printed.
76+* The result of printing is parsed back again and the AST is compared to the
77+ AST obtained from the original file. They should match.
78+* The output of printer is checked against the expected output.
79+* Idempotency property is verified: formatting already formatted code
80+ results in exactly the same output.
81+
82+Examples can be organized in sub-directories, see the existing ones for
83+inspiration.
684
785## License
886
987Copyright © 2018–2019 Tweag I/O
88+
89+[haskell-src-exts]: https://hackage.haskell.org/package/haskell-src-exts
90+[hindent]: https://hackage.haskell.org/package/hindent
91+[bugs]: https://github.com/tweag/ormolu/issues?q=is%3Aissue+is%3Aopen+label%3Abug