Thte last 2 days has been very hectic. Yesterday I came to port my add constructor refactorinng over to use the TI AST instead, and then realised (with horror) that the API only worked over the normal AST.
I then had to create an API which worked over the TI AST, by creating new type synonyms for the TI Exp, Pat and Decls constructors. I then had to copy the AST into a new file RefacTypeUtils and modify it work with the new constructors. This also require modification to refacLocUtils (also copied over to refacTILocUtils).
After all that and more modifications to the TI API to get my refactoring to work I have found something very interesting. Wherever in the program there is an expression of type Int the type checker wraps up the expression in an application of fromInteger expression. And when the API writes the refactored output to the file - lo and behold it also puts this application in its place.
At the moment I can think of some ways to deal with this:
1. Leave it as it is - it doesn't alter the behaviour, the type checker only puts it in to resolve types;
2. Map the normal AST onto the TI AST preserving TI information (therefore removing these from integer applications)
3. Traverse the TI AST to find where ever there is an INT expression and remove the application.
THis is a pain, I have also found another strange perculiarity: My refactoring adds a declaration, and now it adds the declaration with [ ] around it. This must be do with the new TI API playing up over the constructors.
Intriging. I was hoping to have a version of my refactoring completed today which uses type information, but with porting the API and fixing about a million bugs in the port its put me behind schedule.