summaryrefslogtreecommitdiff
path: root/compiler/main/PackageConfig.hs
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@cs.stanford.edu>2014-11-15 00:08:53 -0800
committerEdward Z. Yang <ezyang@cs.stanford.edu>2014-11-15 00:36:03 -0800
commite14a973215102cb3774e3b4370c64edcff0e10bc (patch)
treee5c3e310619fbf642af8a0febaed515030b807a3 /compiler/main/PackageConfig.hs
parent452d6aa95b754a08e1e61800680ccbf6f968aef0 (diff)
downloadhaskell-e14a973215102cb3774e3b4370c64edcff0e10bc.tar.gz
Generalize exposed-modules field in installed package database
Summary: Instead of recording exposed-modules and reexported-modules as seperate fields in the installed package database, this commit merges them into a single field (exposed-modules). The motivation for this change is in preparation for the inclusion of *signatures* into the installed package database, which may also be reexported. Merging the representation means that we can treat reexports uniformly, no matter if they're a normal module or a signature. This commit adds a stub for signatures, but that code isn't wired up to anything yet. Contains Cabal submodule update to accommodate these changes. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: simonpj, duncan, austin Subscribers: thomie, carter, simonmar Differential Revision: https://phabricator.haskell.org/D421
Diffstat (limited to 'compiler/main/PackageConfig.hs')
-rw-r--r--compiler/main/PackageConfig.hs27
1 files changed, 25 insertions, 2 deletions
diff --git a/compiler/main/PackageConfig.hs b/compiler/main/PackageConfig.hs
index 3f2bf1680b..b94ea65a65 100644
--- a/compiler/main/PackageConfig.hs
+++ b/compiler/main/PackageConfig.hs
@@ -75,6 +75,25 @@ instance Outputable SourcePackageId where
instance Outputable PackageName where
ppr (PackageName str) = ftext str
+-- | Pretty-print an 'ExposedModule' in the same format used by the textual
+-- installed package database.
+pprExposedModule :: (Outputable a, Outputable b) => ExposedModule a b -> SDoc
+pprExposedModule (ExposedModule exposedName exposedReexport exposedSignature) =
+ sep [ ppr exposedName
+ , case exposedReexport of
+ Just m -> sep [text "from", pprOriginalModule m]
+ Nothing -> empty
+ , case exposedSignature of
+ Just m -> sep [text "is", pprOriginalModule m]
+ Nothing -> empty
+ ]
+
+-- | Pretty-print an 'OriginalModule' in the same format used by the textual
+-- installed package database.
+pprOriginalModule :: (Outputable a, Outputable b) => OriginalModule a b -> SDoc
+pprOriginalModule (OriginalModule originalPackageId originalModuleName) =
+ ppr originalPackageId <> char ':' <> ppr originalModuleName
+
defaultPackageConfig :: PackageConfig
defaultPackageConfig = emptyInstalledPackageInfo
@@ -101,9 +120,11 @@ pprPackageConfig InstalledPackageInfo {..} =
field "id" (ppr installedPackageId),
field "key" (ppr packageKey),
field "exposed" (ppr exposed),
- field "exposed-modules" (fsep (map ppr exposedModules)),
+ field "exposed-modules"
+ (if all isExposedModule exposedModules
+ then fsep (map pprExposedModule exposedModules)
+ else pprWithCommas pprExposedModule exposedModules),
field "hidden-modules" (fsep (map ppr hiddenModules)),
- field "reexported-modules" (fsep (map ppr haddockHTMLs)),
field "trusted" (ppr trusted),
field "import-dirs" (fsep (map text importDirs)),
field "library-dirs" (fsep (map text libraryDirs)),
@@ -122,6 +143,8 @@ pprPackageConfig InstalledPackageInfo {..} =
]
where
field name body = text name <> colon <+> nest 4 body
+ isExposedModule (ExposedModule _ Nothing Nothing) = True
+ isExposedModule _ = False
-- -----------------------------------------------------------------------------