| 3 | | This could be fixed if we parse Haddock comments separately from the Haskell code, and match up Haddock comments with AST nodes in a later step. |
| | 8 | This is a bug in GHC's parser. It is only triggered if |
| | 9 | [http://www.haskell.org/ghc/docs/latest/html/libraries/ghc/DynFlags.html#v:Opt_Haddock Opt_Haddock] is used. |
| | 10 | |
| | 11 | === Details === |
| | 12 | GHC's parser has a rule for Haddock comments on the module headers. |
| | 13 | When the parser sees the Haddock comment at the |
| | 14 | beginning it then wants the next declaration to be a module header |
| | 15 | (the GHC grammar has an S/R conflict because of this). |
| | 16 | |
| | 17 | One possible solution could be to parse Haddock comments separately from the Haskell code, and match up Haddock comments with AST nodes in a later step. |
| | 18 | |
| | 19 | === Steps to reproduce === |
| | 20 | {{{ |
| | 21 | -- | Hi there |
| | 22 | main = print "Hello World!" |
| | 23 | }}} |
| | 24 | |
| | 25 | Running |
| | 26 | {{{ |
| | 27 | $ haddock Main.hs |
| | 28 | }}} |
| | 29 | fails with: |
| | 30 | {{{ |
| | 31 | Main.hs:2:1: parse error on input `main' |
| | 32 | }}} |
| | 33 | |
| | 34 | In contrast both of the following example work just fine: |
| | 35 | |
| | 36 | {{{ |
| | 37 | {- |
| | 38 | Hi there |
| | 39 | -} |
| | 40 | main = print "Hello World!" |
| | 41 | }}} |
| | 42 | {{{ |
| | 43 | foo = 23 |
| | 44 | -- | Hi there |
| | 45 | main = print "Hello World!" |
| | 46 | }}} |