compiler: port to template haskell

Eliminate the dependency on the GHC API in favor of the more portable
template haskell library.