On Twitter, Anthony Cowley was wondering why there was no GHC API functions for taking Cabal InstalledPackageInfos and turning them into GHC InstalledPackageInfos. https://twitter.com/a_cowley/status/680158885953564672
No such interface exists: to keep GHC decoupled from Cabal, the GHC package representation is mediated solely by
ghc-pkg, so the "correct" way to create a package config file, run
ghc-pkg to load it into the GHC binary representation, and go from there.
It seems like it would be convenient if
ghc-pkg was libified, and so people who linked against GHC and Cabal could just directly do the conversion without going through
ghc-pkg. It's unclear what the right interface is; ghc-pkg does a number of sanity checks and it's unclear if those should be libified too. Any such library also must be uploaded to Hackage, because if you want to link against a newer version of Cabal you have to rebuild the ghc-pkg library against the newest version of Cabal.