Closed tomjaguarpaw closed 4 years ago
The -- $
comment is parsed as a Haddock reference, I assume, which Haddock deems misplaced. There is really nothing Ormolu can do, since it needs to care about the placement of Haddock comments.
But you have workarounds: such as adding an extra space between --
and $
, it should suffice.
Ah yes, that's true. That workaround is OK for now.
But why is Ormolu parsing in Haddock mode? Does it also format Haddock comments?
Does it also format Haddock comments?
It may change how they are placed. For example -- ^
may be reformatted as -- |
this is why we need to parse in Haddock mode.
Interesting, thanks. And thanks for writing Ormolu!
More importantly, Ormolu needs to understand Haddock comments, otherwise, they could easily become detached from the definition they refer to, hence change the generated html documentation (probably to something nonsensical). A problem which, I believe, early versions of Ormolu had.
The best way to understand Haddock comments is to share Haddock's parser. When you get there, it also gives you the freedom to manipulate them a smidge, which @mrkkrp is speaking of above.
I suspect I ought to consider my code incorrect if it doesn't satisfy Haddock. I don't actually have any Haddock docs in it, but it's probably a good habit to get into. On the other hand, I didn't realise that Haddock was actually part of GHC!
Ormolu doesn't work in certain cases when comments contain
$
. To reproduce, run ormolu on a file containing(the space before
--
is essential to demonstrate the bug). Ormolu saysI expected it to be able to parse this file successfully. It is a valid Haskell file. This is version