GHC typecheck API

Németh Boldizsár nboldi at
Thu Nov 30 05:42:24 UTC 2017

Dear GHC developers,

I'm developing a framework for development tools for Haskell. I use the 
GHC API to parse and typecheck the source files. I recently started to 
work on a quick-fix (automatic program correction) for Haskell source 
code (correcting parenthesis problems, like 'putStrLn "xxx" ++ show a' 
==> 'putStrLn ("xxx" ++ show a)'). To do that I need to get the typed 
syntax tree even if the program contains type or rename errors. I could 
only do this by a nasty hack, adding a new TH module finalizer 
(tcg_th_modfinalizers) to extract the type checker's state before it 
fails. Is there a "correct" way to do this? I would not like this 
refactorings to be unusable if the GHC API changes.

By the way, if you know of any similar attempt please let me know.

Boldizsár Németh

More information about the ghc-devs mailing list