fourmolu / fourmolu

A fourk of ormolu that uses four space indentation and allows arbitrary configuration. Don't like it? PRs welcome!
https://fourmolu.github.io/
Other
356 stars 62 forks source link

Confusing docs for `diff-friendly-import-export`. #56

Closed sellout closed 2 years ago

sellout commented 3 years ago

The docs for this option say "Whether to make use of extra commas in import/export lists (as opposed to Ormolu's style)", but Ormolu uses trailing commas on multi-line import and export lists (and I'm pretty sure it has since before fourmolu was forked), which would seem to be the "diff friendly" style.

In #19, tweag/ormolu#409 is referenced, but that issue isn't about commas, but rather the position of the parens.

So, I guess I'm asking for that documentation to be more explicit about how that option actually affects the formatting.

georgefst commented 3 years ago

I agree it could be a lot clearer. What I've been meaning to do is, for each of the config options, show a minimal example of what code looks like with and without it. This could perhaps belong in a new Config.md, linked to from the README and the Hackage docs.

In the case of imports, it's:

import Options.Applicative
    ( Parser,
      argument,
      execParser,
      (<**>),
    )

versus:

import Options.Applicative (
    Parser,
    argument,
    execParser,
    (<**>),
 )

(I very rarely use multi-line imports, so I forgot how much I hate that indentation on the last line - perhaps 2 or 4 would look better than 1. For some reason 0 is allowed for exports but not imports...)

georgefst commented 3 years ago

Looking at that, the docs probably shouldn't mention extra commas at all.

istathar commented 3 years ago

I just ran this experiment and had the same observations as @georgefst. I agree, the last comma is a bit jarring when this option is set to false.

brandonchinn178 commented 2 years ago

Fixing this as part of #169