-
Notifications
You must be signed in to change notification settings - Fork 81
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
Fix AST diffing for empty Haddock comments in data decls #1068
Conversation
Oh no! This is very unfortunate, and so is #818. Empty Haddock comments are semantically meaningful. They cause the Haddock output to wrap. For further information see
Ormolu obliterates this nice formatting :( Granted, using |
Interesting, that is a very nice trick; but it doesn't seem to work anymore 😭: You link to Maybe this should be considered to be an upstream GHC issue? If empty Haddock comments appear in the AST again, it will also be easier for Ormolu to preserve them. WDYT? |
I can also confirm locally that your trick works on GHC 8.10, but does no longer work since 9.0. |
Thanks for a very speedy reply! Oh, yes, I see. I didn't realise that this had changed, and I didn't realise I hadn't checked the latest documentation. I guess the two versions were generated by the builder at times straddling the change to GHC 9.x for Haddock generation.
I suppose that seems reasonable but I'd still prefer to have
even though that won't get me any benefit under GHC 9.x (yet ...). Anyway, it's your application (which I enjoy using a lot) and your effort, so please do what you think is most appropriate. In fact, now that I come to think of it, I don't understand why formatting |
I actually like your suggested behavior (though I would probably not treat I think the proper fix is to actually change the GHC parser behavior as mentioned above, I opened https://gitlab.haskell.org/ghc/ghc/-/issues/23935 for that. I think that would also re-enable your Haddock trick, I tagged you there (hope that is fine).
We preprocess the AST to remove Haddock comments that are all blank (this PR is extending this preprocessing step). I will open a new issue here about preserving blank Haddock comments (as suggested by you) if the reaction in the GHC ticket is positive; once we upgrade to a GHC that has the fix, we can remove the code that eg this PR is touching. In the meantime, I think that this PR is still an incremental improvement (it certainly doesn't make anything worse). |
I think that would be even better if it fits with the constraints. I still don't fully understand the behaviour of the GHC parser and how that impinges.
Yes, absolutely, thanks for doing that. |
Closes #1065, by basically amending #818 with another case where Haddock comments can occur