HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulehaskell-src-exts-1.23.1Haskell98

Language.Haskell.Exts.Comments

This module processes comments along with an annotated AST, to be able to associate Haddock comments with the actual item they refer to.

Example:

let
 parse1Result :: ParseResult (Module SrcSpanInfo,[Comment])
 parse1Result =
   parseFileContentsWithComments
    (defaultParseMode { parseFilename = file })
     contents
 withC :: ParseResult (Module (SrcSpanInfo,[Comment]))
 withC = case parse1Result of
           ParseOk res         -> ParseOk $ associateHaddock res
           ParseFailed sloc msg -> ParseFailed sloc msg

In this code sample, parse1Result is what you get when you parse a file: a Module annotated wth SrcSpanInfo, and a list of comments After passing the result to associateHaddock, you get a Module annotated with both a SrcSpanInfo and the list of Comment related to the specific AST node.

  • 2 types
  • 1 value
datadata Comment
#

A Haskell comment. The Bool is True if the comment is multi-line, i.e. {- -}.

Instances3Eq, Data, Show
  • Eq CommentDefined in haskell-src-exts-1.23.1 · Language.Haskell.Exts.Comments
  • Data CommentDefined in haskell-src-exts-1.23.1 · Language.Haskell.Exts.Comments
  • Show CommentDefined in haskell-src-exts-1.23.1 · Language.Haskell.Exts.Comments