tweag / ormolu

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

Docstring in a where clause is removed #715

Closed Profpatsch closed 3 years ago

Profpatsch commented 3 years ago

Describe the bug

The following snippet

foo = ()
  where
     -- | foo
     x = ()

is changed by ormolu to

foo = ()
  where
    x = ()

that is the comment is deleted.

If I use a normal comment like

foo = ()
  where
    -- foo
    x = ()

that comment is preserved.

I ran into this, because I have a habit of documenting where-clauses with normal docstrings, which means promoting a where clause into a toplevel function is just a dedent away.

Environment

mheinzel commented 3 years ago

I think this is a known limitation of the GHC parser: https://github.com/tweag/ormolu/issues/474 It seems like it will be fixed by switching to ghc-lib-parser-9.0.1 in the future.

mrkkrp commented 3 years ago

Yeah, this is a duplicate of #474. It should be fixed as part of 2021 Ormolu internship.

Profpatsch commented 3 years ago

Great, just saw the changelog! Does that mean it’s fixed when I use ormolu 0.2.x.x with GHC 9.x.x?

mrkkrp commented 3 years ago

@Profpatsch I'll probably be fixed when we switch to 9.2 see https://github.com/tweag/ormolu/issues/474#issuecomment-889182337.