+
+-- | Turn a 'PackageConfig', which contains GHC 'Module.ModuleName's into a Cabal specific
+-- 'InstalledPackageInfo' which contains Cabal 'Distribution.ModuleName.ModuleName's
+packageConfigToInstalledPackageInfo :: PackageConfig -> InstalledPackageInfo
+packageConfigToInstalledPackageInfo
+ (pkgconf@(InstalledPackageInfo { exposedModules = e,
+ hiddenModules = h })) =
+ pkgconf{ exposedModules = map convert e,
+ hiddenModules = map convert h }
+ where convert :: Module.ModuleName -> Distribution.ModuleName.ModuleName
+ convert = (expectJust "packageConfigToInstalledPackageInfo") . simpleParse . moduleNameString
+
+-- | Turn an 'InstalledPackageInfo', which contains Cabal 'Distribution.ModuleName.ModuleName's
+-- into a GHC specific 'PackageConfig' which contains GHC 'Module.ModuleName's
+installedPackageInfoToPackageConfig :: InstalledPackageInfo -> PackageConfig
+installedPackageInfoToPackageConfig
+ (pkgconf@(InstalledPackageInfo { exposedModules = e,
+ hiddenModules = h })) =
+ pkgconf{ exposedModules = map convert e,
+ hiddenModules = map convert h }
+ where convert :: Distribution.ModuleName.ModuleName -> Module.ModuleName
+ convert = mkModuleName . display