Extracting representation from GHC

Németh Boldizsár nboldi at elte.hu
Fri Jan 19 09:35:29 UTC 2018


Dear GHC Developers,

I would like to ask your opinion on my ideas to make it easier to use 
development tools with GHC.

In the past when working on a Haskell refactoring tool I relied on using 
the GHC API for parsing and type checking Haskell sources. I extracted 
the representation and performed analysis and transformation on it as it 
was needed. However using the refactorer would be easier if it could 
work with build tools.

To do this, my idea is to instruct GHC with a compilation flag to give 
out its internal representation of the source code. Most build tools let 
the user to configure the GHC flags so the refactoring tool would be 
usable in any build infrastructure. I'm thinking of using the 
pre-existing plugin architecture and adding two new fields to the Plugin 
datastructure. One would be called with the parsed representation 
(HsParsedModule) when parsing succeeds, another with the result of the 
type checking (TcGblEnv) when type checking is finished.

What do you think about this solution?

Boldizsár

(ps: My first idea was using frontend plugins, but I could not access 
the representation from there and --frontend flag changed GHC 
compilation mode.)



More information about the ghc-devs mailing list