tweag / ormolu

A formatter for Haskell source code
https://ormolu-live.tweag.io
Other
950 stars 83 forks source link

Don't let comments escape from empty export lists #1013

Closed amesgen closed 1 year ago

amesgen commented 1 year ago

Closes #906, see https://github.com/tweag/ormolu/pull/933#issuecomment-1369080586 for more context. The main advantage of this PR to #933 is that it is much more minimal, bu it is still relatively ad-hoc.

There is a similar issue in other cases, e.g. also with this PR (or also with #933), comments "escape" here:

data Foo = Foo {
  -- foo
  }

foo = [
  -- foo
  ]

foo = (
  -- foo
  )

See https://github.com/tweag/ormolu/commit/54dfe3ebe3d30f4b248eba7192b400ca477c6a97 for an approach to call encloseLocated "automatically" via an overlapping instance, which e.g. "catches" the comment in the first case in the example above. The other two would probably need ad-hoc handling in p_rdrName.

github-actions[bot] commented 1 year ago

🚀 Deployed on https://5f70b3d792ae8646db3d71a9aeb80f407b8a6fe9--ormolu-live.netlify.app