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 .hcr
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.
Related: Using GHC API to compile Haskell sources to CORE and CORE to binary discusses the .hcr
format and a GHC API that might help, but AFAICT the OP's question wasn't actually answered. Would a GHC plugin help here?