如何将IO值编译到Haskell中的程序中?

我的问题仅基于好奇心,而不是良好的开发实践或目的/效用。

如何将Haskell中的IO值编译为二进制文件,而不是将Haskell源文件编译为二进制文件?

main = runGhc (Just libdir) . liftIO $ putStrLn "hello world"

From this working snippet where libdir is a filepath to my GHC library, it appears I can interpret arbitrary IO values but I have trouble compiling them.

我试过的是将一个空文件编译为一个核心程序,然后尝试将它们与Ghc monad组合在一起,但不确定其工作原理。我在网上阅读了Ghc monad嵌入计算的信息。

(liftIO $ putStrLn "hello world") *> compileToCoreSimplified (plain :: FilePath) :: Ghc CoreModule

plain being the full path to some file that is just main = pure ().