[Haskell-cafe] ghc-api Static Semantics?

Christopher Brown cmb21 at st-andrews.ac.uk
Tue Jan 24 11:04:10 CET 2012


Hi Ozgur,

Yes I've looked at haskell-src-exts and it does look *much* easier to use.

I need this to build a new refactoring tool for Haskell (for the Paraphrase project). One advantage to using the ghc-api directly
is that's it's always cutting edge and maintained by the ghc team. Having one more library dependancy to worry about is not always a good thing.

At the moment (and spending half a day yesterday just working out how to 'show' an AST from the ghc-api) I'm veering towards haskell-src-exts. I think extending it to contain use and bind locations in the AST would be the best option for me. There's also a question of having types in the AST as well.

> I don't know what you actually need, but if haskell-src-exts is an option, it is quite a bit easier to use (definitely easier to understand for me!). Especially when used together with Uniplate.
> 
> For example, for a given piece of AST one can get all the identifiers used like so:
> 
> [ x | Ident x <- universeBi ast ]
> 

Uniplate isn't a powerful enough generic system to design a full refactoring engine, as we need top down/bottom up/ full/stop/once plus preservation and unification, much in the style of Strafunski. I think SYB is better for our needs. Perhaps we could use a combination of uniplate+SYB depending on what traversals/rewrites we need to do.


> Finding where they are bound shouldn't be very hard either.
> 

No, but it would be much easier if the information was already there, of course! :)


Thanks for your response! 
Chris.

> Hope this helps,
> Ozgur
> 
> On 23 January 2012 17:33, Christopher Brown <cmb21 at st-andrews.ac.uk> wrote:
> Hi,
> 
> I was wondering if anyone could tell me if it's possible to get an AST from the ghc-api decorated with static-semantics?
> In particular, I am interested in use and bind locations for all names in the AST together with the module they are bound, etc.
> 
> Looking through the online docs, there doesn't seem to be a way to do this.
> Even if I can tell from the AST where a variable is bound that would be enough,  if this is by making all names unique and qualified that would be better than nothing.
> 
> Hope someone can help,
> Chris.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120124/a066ab9e/attachment.htm>


More information about the Haskell-Cafe mailing list