[Haskell-cafe] Retrieving Haddock comments with haskell-src-exts
AntC
anthony_clayden at clear.net.nz
Thu Aug 22 07:43:49 CEST 2013
> Niklas Broberg <niklas.broberg <at> gmail.com> writes:
>
> Hmm. I see the difficulty here, ...
>
> On Wed, Aug 14, 2013 at 8:57 PM, Mateusz Kowalczyk wrote:
> ...
> The main problem with this approach is that we get comments (and their
> SrcLoc) as a separate list.
Hi Niklas, Mateusz,
It seems that haskell-src-exts has done quite a lot of the hard work
(impressive!).
Function parseFileWithComments returns the AST annotated with SrcLoc for
each major node, and with a separate list of comments annotated with
SrcSpan. So it should be possible to reconstitute the source and
intersperse the comments between the nodes(?) -- or detect where a comment
spans code.
(I'm also looking at the discussion about comments on Niklas's
announcement of 1.14.0 )
Could there be a style of prettyPrint that carries the list of comments
(as a continuation) alongside walking the AST, and consumes/outputs each
comment where the comment's Span falls between the nodes' Loc? Would this
need too much lookahead?
(And thank you to Adam for introducing me to the joys of source-munging.
http://www.haskell.org/pipermail/haskell-cafe/2013-August/108426.html .)
AntC
More information about the Haskell-Cafe
mailing list