Language.Haskell.Exts.Comments

haskell-src-exts-1.18.2: Manipulating Haskell source: abstract syntax, lexer, parser, and pretty-printer

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.

Synopsis

- 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]) #

Associates an AST with Source Span Information with relevant Haddock comments

data Comment #

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

Constructors

Comment Bool SrcSpan String |

Instances

Eq Comment # |
Methods (==) :: Comment -> Comment -> Bool # (/=) :: Comment -> Comment -> Bool #
Data Comment # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Comment -> c Comment # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Comment # toConstr :: Comment -> Constr # dataTypeOf :: Comment -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Comment) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Comment) # gmapT :: (forall b. Data b => b -> b) -> Comment -> Comment # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Comment -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Comment -> r # gmapQ :: (forall d. Data d => d -> u) -> Comment -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Comment -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Comment -> m Comment # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Comment -> m Comment # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Comment -> m Comment #
Show Comment # |
Methods showsPrec :: Int -> Comment -> ShowS # show :: Comment -> String # showList :: [Comment] -> ShowS #

data UnknownPragma #

An unknown pragma.

Constructors

UnknownPragma SrcSpan String |

Instances

Eq UnknownPragma # |
Methods (==) :: UnknownPragma -> UnknownPragma -> Bool # (/=) :: UnknownPragma -> UnknownPragma -> Bool #
Data UnknownPragma # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> UnknownPragma -> c UnknownPragma # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c UnknownPragma # toConstr :: UnknownPragma -> Constr # dataTypeOf :: UnknownPragma -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c UnknownPragma) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UnknownPragma) # gmapT :: (forall b. Data b => b -> b) -> UnknownPragma -> UnknownPragma # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> UnknownPragma -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> UnknownPragma -> r # gmapQ :: (forall d. Data d => d -> u) -> UnknownPragma -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> UnknownPragma -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> UnknownPragma -> m UnknownPragma # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> UnknownPragma -> m UnknownPragma # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> UnknownPragma -> m UnknownPragma #
Show UnknownPragma # |
Methods showsPrec :: Int -> UnknownPragma -> ShowS # show :: UnknownPragma -> String # showList :: [UnknownPragma] -> ShowS #