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

Mateusz Kowalczyk fuuzetsu at fuuzetsu.co.uk
Wed Aug 14 20:57:15 CEST 2013


On 14/08/13 19:02, Niklas Broberg wrote:
> Hi Mateusz,
>
> haskell-src-exts is not haddock-aware I'm afraid, so I don't have any real
> solution for you. The one you mention, i.e. going through the whole parse
> result and stiching things together manually seems like the best bet if you
> want to use haskell-src-exts throughout.
The main problem with this approach is that we get comments (and their
SrcLoc) as a separate list. While it's trivial to check whether the
comment starts with a ‘|’ or ‘^’ and it's not even hard to find any lines
immediately following it, Haddock comments can appear in weird
positions and trail until a line of code is encountered. Right now,
it's rather hard to tell

  -- | Foo

  -- bar
and

  -- | Foo
  someCode = undefined
  -- bar

apart. I think this is the only option at the moment if I'm to use
haskell-src-exts.
>
> In the longer run, it would be nice to have haddock support in
> haskell-src-exts, so ideas regarding what kind of interface you would like
> to see are most welcome. :-)
For my use, I do not care about anything but Haddock comments. I don't
care where or why they appear, what they are attached to &c. With my
current method, I just throw all this information away (it's given by
GHC).

For general use, I imagine that it'd be useful for the program to
combine multi-line Haddock comments into a single one and attach it to
whatever it is documenting. I'm not sure how haskell-src-exts is
implemented but I don't think it's plausible to do this without going
out to GHC and asking it for the information. Incidentally, this is
precisely the problem I'm trying to solve with help of haskell-src-exts.

>
> Cheers, Niklas
>
Thanks!

--
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/ab23f7d5/attachment.key>


More information about the Haskell-Cafe mailing list