| Copyright | (c) JP Moresmau 2015 |
|---|---|
| License | BSD-style (see the file LICENSE.txt) |
| Maintainer | Niklas Broberg, d00nibro@chalmers.se |
| Stability | experimental |
| Portability | portable |
| Safe Haskell | Safe |
| Language | Haskell98 |
Language.Haskell.Exts.Comments
Description
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.
- associateHaddock :: (Annotated ast, Traversable ast) => (ast SrcSpanInfo, [Comment]) -> ast (SrcSpanInfo, [Comment])
- data Comment = Comment Bool SrcSpan String
- data UnknownPragma = UnknownPragma SrcSpan String
Documentation
associateHaddock :: (Annotated ast, Traversable ast) => (ast SrcSpanInfo, [Comment]) -> ast (SrcSpanInfo, [Comment]) Source #
Associates an AST with Source Span Information with relevant Haddock comments