Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indent post-guard expression one level more #806

Closed
brandonchinn178 opened this issue Oct 15, 2021 · 3 comments · Fixed by #813
Closed

Indent post-guard expression one level more #806

brandonchinn178 opened this issue Oct 15, 2021 · 3 comments · Fixed by #813
Assignees
Labels
style Nitpicking and things related to purely visual aspect for formatting.

Comments

@brandonchinn178
Copy link
Collaborator

brandonchinn178 commented Oct 15, 2021

Is your feature request related to a problem? Please describe.
Currently, expressions are indented just one more indentation level after a guard, which makes me confuse the guard from the expression. e.g.

foo mx
  | Foo x <- mx = do
    Foo x' <- bar x
    return x'
  | otherwise = do
    putStrLn "hello"
    putStrLn "world"

When I look at this, my eyes glaze over the | and just see 6 lines at the same indentation level.

Describe the solution you'd like
I think it's less confusing for it to be indented one more, e.g.

foo mx
  | Foo x <- mx = do
      Foo x' <- bar x
      return x'
  | otherwise = do
      putStrLn "hello"
      putStrLn "world"

To me, this is much clearer, as it clearly separates the guard from the expression. I can clearly see two guards, with two lines of expression each, whereas before, I saw 6 lines of guards/expressions?

Describe alternatives you've considered

Additional context

@mrkkrp mrkkrp added the style Nitpicking and things related to purely visual aspect for formatting. label Oct 16, 2021
@mrkkrp mrkkrp changed the title Indent post-guard expression one more Indent post-guard expression one level more Oct 18, 2021
@tbagrel1 tbagrel1 linked a pull request Oct 21, 2021 that will close this issue
@epoberezkin
Copy link

Changes like that are really frustrating and undermine "opinionated formatter" positioning, to be honest.

Either opinions should never change, really, or options should be added, otherwise you make what started as a useful tool into a very annoying tool creating a lot of unnecessary noise in the source code whenever you change the version...

See #1061

@brandonchinn178
Copy link
Collaborator Author

Changes like that are really frustrating

I'm curious what you find frustrating about it. Is it simply that it's a change in behavior (and an opinionated formatter should never change), or is it that you actually prefer it unindented? To put it in a different way, if the change were reversed (i.e. ormolu initially indented post-guard expressions and a change was made to unindent them), would you be similarly frustrated?

@epoberezkin
Copy link

Thanks for asking. Absolutely, I would be as frustrated :)

Ormolu didn’t offer the style I used before using ormolu, it was VERY different - I used leading commas, leading arrows in multiline types, etc.

But the appeal of having no arguments about style with other people was much stronger than any particular style, so I accepted the fact that it’s just different and got used to it.

So seeing it change as arbitrarily when moving to the latest version (and not that I want to move to it, but we have to, to support 9.6.2 parser) is frustrating, whatever the change is, irrespective of whether it makes formatting better or worse - it creates noise in the diff and conflicts with other branches, and also creates a cognitive overload to adjust the “parser” in the brain to the new style, reducing the speed of reading code until this adjustment happens.

The main value of ormolu for me was “here is the style, use it, no need to argue about it”, and it was great because I’ve seen every team spending A LOT of time arguing. The value of consistent and unchanging style is in saving time, as you don’t have to re-wire your brain, and not in aesthetics or readability of particular style - anything is readable once you get used to it.

But anyway, no combination of options in fourmolu allows to keep the original ormolu style (that is, no parents for single type classes and no indentation for guards, so I’ll just have to live with the new style now, fix the conflicts and get used to it :)

I’ll just hope that if you decide to change it again there at least will be option to avoid this change… The need to add this option would make this change less likely to happen, so the value of this change would need to be higher for it to happen, which is also good for everybody.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
style Nitpicking and things related to purely visual aspect for formatting.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants