Closed amesgen closed 4 months ago
I opened a GHC ticket for this: https://gitlab.haskell.org/ghc/ghc/-/issues/24221
But aside from that issue, it seems like Ormolu doesn't format a fully documented infix constructor correctly anyway. Here's an example:
data Foo
= Int -- ^ Docs for left arg
:*: -- ^ Docs for constructor
Int -- ^ Docs for right arg
This fails to output valid Haskell:
<input>
@@ -1,4 +1,8 @@
data Foo
- = Int -- ^ Docs for left arg
- :*: -- ^ Docs for constructor
- Int -- ^ Docs for right arg
+ = -- | Docs for constructor
+
+ -- | Docs for left arg
+ Int
+ :*: -- | Docs for right arg
+ Int
+
AST of input and AST of formatted code differ.
at <input>:2:5-7
at <input>:2:9-30
Please, consider reporting the bug.
To format anyway, use --unsafe.
FYI GHC 9.10 fixed the issue originally documented. But I'll fix the issue I brought up in the thread
Describe the bug This snippet can't be formatted without
--unsafe
(minimized from Agda):With
--unsafe
, it is formatted toIn the first case, the Haddock comment is attached to the constructor
:#
, but in the second case, it is attached to the first argument of:#
.Expected behavior It could be formatted like this to preserve the AST:
But this is not really nice from a sylistic perspective (we should not have to break apart an existing single line constructor variant).
Environment Ormolu 0.2.0.0
Additional context This changed in GHC 9.0; previously, both snippets had the same AST.