I am working with HsSyn Name, resulting from calling.typecheckModule from the GHC API.
This seems to give a workable balance between the ParsedSource which is lexically close to the original source but lacks grouping of related elements, and the TypecheckedSource which has had the type information reduced to the type checker output.
I am not sure which of the two type signatures is the "right" one for a refactorer. The commented out one preserves that the original baz returns an Int, and splices in the xx signature, the uncommented one is as generated by GHC 7.6.3 when using the :i command in ghci.
The API calls I would like to make would be something like
which would take a modified ParsedModule (or RenamedSource, or whatever context is required), restore the original type checking environment, and redo the type checking phase.
This would then allow a query something like the existing getInfo call to retrieve the inferred type.
Alternatively, explicitly putting a typed hole in for the required signature as part of the changes going in to the call to reTypecheckModule and then processing the returned warnings would work just as well.
But I suspect I should poke around in the internals a bit more to clarify my question by trying to actually do it.
Alan