Skip to content
  • Vladislav Zavialov's avatar
    Accumulate Haddock comments in P (#17544, #17561, #8944) · 19e80b9a
    Vladislav Zavialov authored and Ben Gamari's avatar Ben Gamari committed
    Haddock comments are, first and foremost, comments. It's very annoying
    to incorporate them into the grammar. We can take advantage of an
    important property: adding a Haddock comment does not change the parse
    tree in any way other than wrapping some nodes in HsDocTy and the like
    (and if it does, that's a bug).
    
    This patch implements the following:
    
    * Accumulate Haddock comments with their locations in the P monad.
      This is handled in the lexer.
    
    * After parsing, do a pass over the AST to associate Haddock comments
      with AST nodes using location info.
    
    * Report the leftover comments to the user as a warning (-Winvalid-haddock).
    19e80b9a