title: Using GHC to compile Core
body: <p>I want to write a compiler from another language to produce terms in Haskell Core, and call GHC on the result. Are there any methods to do this? The compiler is not written in Haskell, so it would have to communicate via a serialization format or FFI. I have read about <code>.hcr</code> files for getting core from GHC, but I don't know how to read it back in to finish compilation. Alternatively, I could try to write a plain Haskell file, but this would require a lot of explicit type applications and quoted identifiers, and it seems error prone.</p>
  
  <p>Related: <a href="https://stackoverflow.com/q/28059669/890016">Using GHC API to compile Haskell sources to CORE and CORE to binary</a> discusses the <code>.hcr</code> format and a GHC API that might help, but AFAICT the OP's question wasn't actually answered. Would a GHC plugin help here?</p>