Open einargs opened 4 years ago
We might also be able to use Ormolu: https://www.tweag.io/posts/2019-10-11-ormolu-first-release.html
It makes some strange formatting choices though (but does have some justification for them), and is in beta, so I wouldn't consider it a top contender.
What do you think of this comment? https://www.reddit.com/r/haskell/comments/8x0x77/brittany_vs_hindent_vs_stylishhaskell/e2076ig/
I watched several tutorials online with a guy who just used hlint
and hindent
. I like sticking to a standard rather than going for aesthetics (though hopefully the standard is also aesthetic).
For example, if I were doing a C style guide I'd prefer to always have this:
if (SOME_PREDICATE) {
// something
}
over
if (SOME_PREDICATE) // something
even if the latter is more compact because consistency is readable.
For that reason I like both hindent
according to the above reddit comment, but also Ormolu, which both considers standardization as well as questions the previous rationale, for example, with leading commas in multiline lists. I also like that GHC supports trailing commas now, did not know that.
We should pick out an auto-formatter, and decide on how many spaces we want to use for indents. My vote is for 2 spaces.
It looks like Brittany is the state of the art for Haskell formatters, since it uses the GHC parser. There's also
hindent
andstylish-haskell
: https://www.reddit.com/r/haskell/comments/8x0x77/brittany_vs_hindent_vs_stylishhaskell/