[Haskell-cafe] Retrieving Haddock comments with haskell-src-exts

Mateusz Kowalczyk fuuzetsu at fuuzetsu.co.uk
Wed Aug 14 16:57:12 CEST 2013

I'm writing a small tool to help to analyse Haddock comments in
Haskell source files to help me to indicate any potential breakage to
documentation in existing source files.

Currently I'm doing the parsing with the GHC's ‘parser’ function with
Opt_Haddock set and I filter out everything I don't need. There are
problems with this approach: determining any extensions and options
used is vital for valid parsing of the files and a large amount of
source files outright fails to parse without this information.

Fortunately, haskell-src-exts exists and it can deal with all (or
most) of this for me. Unfortunately, there doesn't seem to be any way
to get it to recognise Haddock comments and the only option available
is all comments or no comments at all. It's not easily possible to
stitch these together without analysing the whole parse result.

Currently I'm thinking of parsing out extensions and pragmas used
using haskell-src-exts and then feeding those to GHC, effectively
parsing the second time. Is there a way to avoid this?

There's ‘lexTokenStream’ but I believe it has similar problems to
‘parser’, that is, needing to know the extensions beforehand.
Mateusz K.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0x2ADA9A97.asc
Type: application/pgp-keys
Size: 5619 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130814/9db077ea/attachment.key>

More information about the Haskell-Cafe mailing list