Let Template Haskell dynamically add something with which to link
As of today, Template Haskell supports emitting foreign files (for C compiler languages) via
addForeignFile. In doing so, GHC takes on the work of compiling these, linking them, and then cleaning up any other files.
This makes packages like
inline-c (https://hackage.haskell.org/package/inline-c) possible, where you can write C snippets in quasiquotes and these can interact with your Haskell code. The user doesn't need to pass extra options to GHC (except to enable the right language extensions), and they don't have to see any of the intermediate generated artifacts.
Unfortunately, that breaks down for non C compiler languages. It would be nice for TH to also support directly adding something to pass to the linker, since then one could
- use TH's
runIOto generate libraries or object files by calling out to whatever other compilers
- add those via TH
- have GHC statically link against the content (from the second bullet point)
I'm not sure what the API for this could be, but maybe
- add a
LangLinkableconstructor to the
- add a
qAddForeignFilePath :: ForeignSrcLang -> FilePath -> m ()method to