This is not using haskell-src-exts, but the Haskell Refactorer has a
structure to keep a parallel tree of tokens indexed by SrcSpan, which
attempts to allocate comments to the appropriate point.

See
https://github.com/alanz/HaRe/blob/master/src/Language/Haskell/Refact/Utils/TokenUtils.hs.
It does not make use of the AST itself, so may be usable with
haskell-src-exts

Alan




On Tue, Aug 20, 2013 at 11:19 AM, Niklas Broberg
<niklas.brob...@gmail.com>wrote:

> Hi Niklas,
>
> 1) My most desired feature would be a syntax tree that does not pluck
>> pluck comments out and make me treat them separately. It looks much
>> easier to me to have a fully descriptive tree and (filter . concatMap) /
>> traverse them out in some way than getting a list of comments and having
>> to insert them back in the right places myself.
>> Is that possible?
>>
>
> Sadly not - it's theoretically impossible. The fact that you can put
> comments literally wherever, means that it's impossible to treat them as
> nodes of the AST. E.g.
>
>   f {- WHERE -} x = -- WOULD
>       -- THESE
>       do -- COMMENTS
>          a {- END -} <- g x -- UP
>          return {- ? -} a
>
> What would be theoretically possible is to define a restricted language
> that allows comments only in certain well-defined places (cf haddock), and
> ignores any others. That's a lot of work though, and it's not clear how big
> the gain is. :-\
>
> A different solution could be to improve the support, through better
> helper functions, for handling a syntax tree and a list of comments
> together. That's something I think could be worthwhile.
>
>
>> 2) Have you considered downloading the all-of-Hackage tarball and
>> running haskell-src-exts over it to get a benchmark of how much HSE can
>> already parse of the Haskell code out there?
>>
>
> Considered, yes. Done, no. Would love to see the results :-). The crew at
> OdHac (Roman, Erik, Simon) ensured that the current version handles all of
> 'base', which is a good start.
>
> Cheers, Niklas
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to