-
Notifications
You must be signed in to change notification settings - Fork 32
HCAR Draft
ghc-exactprint
aims to be a low-level foundation for refactoring tools. Unlike most refactoring tools, it works directly with the GHC API which means that it can understand any legal Haskell source file.
The program works in two phases. The first phase takes the output from the parser and converts all absolute source positions into relative source positions. This means that it is much easier to manipulate the AST as you do not have to worry about updating irrelevant parts of your program. The second phase performs the reverse process, it converts relative source positions back into a source file. The entire library is based around a free monad which keeps track of which annotations should be where. Each process is then a different interpretation of this structure.
In theory these two processes should be entirely separate but at the moment they are not entirely decoupled due to shortcomings we hope to fix in GHC 7.12.
In order to verify our foundations, the program has been run on every source file on Hackage. This testing highlighted a number of bugs which have been fixed for GHC 7.10.2. Apart from a few outstanding issues with very rare cases, we can now confidently say that ghc-exactprint
is capable or processing any Haskell source file.
The goal for the next few months is to put this tool into action. Alan Zimmerman will be working to integrate ghc-exactprint
into HaRe
whilst Matthew Pickering will be participating in Google Summer of Code to provide integration with HLint
. In order to facilitate both these processes, we anticipate that an intermediate user-level library may be useful to abstract away from the (quite gory) implementation. We hope that this library would also be useful for other tool writers.