ormolu icon indicating copy to clipboard operation
ormolu copied to clipboard

non-diff-friendly behavior with `$`

Open sellout opened this issue 4 years ago • 4 comments

Describe the bug The positioning of $ changes depending other line breaks in the expression.

To Reproduce

shortExpr $
  otherExpr

Now add a composition before the application:

shortExpr . composedExpr $
  otherExpr

So far, so good, but if composedExpr makes the line too long, I break it:

shortExpr
  . composedExpr $
  otherExpr

Then Ormolu reformats it like

shortExpr
  . composedExpr
  $ otherExpr

changing the otherExpr line, which was previously diff-clean. This seems to go against the diff-friendliness of Ormolu. Also, AFAICT, it's special handling of $ -- other operators seem to always be after a line break, but I'm not sure if that's true or if there's a subtle distinction I'm missing.

Expected behavior Probably, I expect the first expression above to be formatted

shortExpr
  $ otherExpr

keeping the second line stable no matter how long the expression before it gets. In fact, this formatting keeps both the shortExpr and otherExpr line clean, and the current behavior makes them both dirty.

Environment

  • OS name + version: NixOS 20.03
  • Version of the code: 0.3.1

Additional context

sellout avatar May 17 '20 21:05 sellout

This got worse recently, with every added foo $ in the pipeline shifting the subsequent expression block by two chars.

foo =
  x $
    y $ do
      a
      b

neongreen avatar Nov 10 '20 12:11 neongreen

This got worse recently

The example may look ugly with single-letter names, but IMO that's on single-letter names.

reasonably =
  namedWrapper $
    doingSomeStuff $ do
      this
      that

dpwiz avatar Apr 09 '21 13:04 dpwiz

Sure. The problem is that I can't choose whether I want namedWrapper $ doingSomeStuff $ do to be on one line or two lines. I have to replace $ with ..

neongreen avatar Apr 09 '21 13:04 neongreen

No wait, nevermind, that's an unrelated problem.

neongreen avatar Apr 09 '21 13:04 neongreen