tweag / ormolu

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

Haddock (GHC 8.4) parse error on type signature documentation #624

Closed basile-henry closed 4 years ago

basile-henry commented 4 years ago

Describe the bug The format used for type signatures and the accompanying documentation does not parse in haddock from GHC 8.4. It does however parse properly with more recent versions of GHC. I came across this when I tried to use repline (formatted with ormolu) in dhall (still using GHC 8.4). https://github.com/sdiehl/repline/issues/31

To Reproduce

The following module (formatted with ormolu) does not parse properly in haddock from GHC 8.4:

module HaddockIssue where

haddockIssue ::
  -- | Docs
  Int ->
  Bool
haddockIssue = undefined
➜ nix-shell -p ormolu haskell.packages.ghc844.ghc --run "ormolu -m inplace HaddockIssue.hs && haddock HaddockIssue.hs"
Haddock coverage:

HaddockIssue.hs:4:3: error: parse error on input ‘-- | Docs’
  |
4 |   -- | Docs
  |   ^^^^^^^^^

Expected behavior I expect ormolu formatted code to still parse properly in GHC 8.4 haddock.

Environment

➜ nix-shell -p ormolu haskell.packages.ghc844.ghc --run "ormolu --version && ghc --version && haddock --version"
ormolu 0.0.3.1 UNKNOWN UNKNOWN
using ghc-lib-parser 8.8.2.20200205
The Glorious Glasgow Haskell Compilation System, version 8.4.4
Haddock version 2.20.0, (c) Simon Marlow 2006
Ported to use the GHC API by David Waern 2006-2008
mrkkrp commented 4 years ago

That version of Haddock/GHC is buggy. We probably can't fix it and definitely won't.

mrkkrp commented 4 years ago

To clarify: it just doesn't make much sense to try to fix this issue with old GHC when it has been fixed in more recent versions. It is just not an efficient way to use our time.