Jose A. Lopes | 31 Jul 15:18 2013
Picon

Template Haskell and Haddock

Hi,

Is there a way to access docstrings through Template Haskell ?
For example, access the docstring of a function declaration ?

Best regards,
Jose
kudah | 31 Jul 19:29 2013
Picon

Re: Template Haskell and Haddock

On Wed, 31 Jul 2013 15:18:32 +0200 "Jose A. Lopes"
<jabolopes <at> google.com> wrote:

> Is there a way to access docstrings through Template Haskell ?
> For example, access the docstring of a function declaration ?

No, but I believe you can access comments and annotations using a
ghc plugin. See https://github.com/thoughtpolice/strict-ghc-plugin for example.
Simon Hengel | 31 Jul 21:05 2013
Picon

Re: Template Haskell and Haddock

On Wed, Jul 31, 2013 at 08:29:18PM +0300, kudah wrote:
> On Wed, 31 Jul 2013 15:18:32 +0200 "Jose A. Lopes"
> <jabolopes <at> google.com> wrote:
> 
> > Is there a way to access docstrings through Template Haskell ?
> > For example, access the docstring of a function declaration ?
> 
> No, but I believe you can access comments and annotations using a
> ghc plugin. See https://github.com/thoughtpolice/strict-ghc-plugin for example.

By default, Haddock comments are not part of GHC's AST.  You need to
explicitly enable it (see e.g. [1]).  For code that extracts all Haddock
comments by using the GHC API, you can look at [2].

Cheers,
Simon

[1] https://github.com/sol/doctest-haskell/blob/master/src/GhcUtil.hs#L66
[2] https://github.com/sol/doctest-haskell/blob/master/src/Extract.hs

Gmane