diff options
author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2014-07-31 18:11:22 +0100 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2014-08-04 18:06:06 +0100 |
commit | edff1efa74edcfa9db0010ae92e1e159ecb60b7e (patch) | |
tree | 383a8ad2ab3a1cc819b8cad379fc5e86e7c95300 | |
parent | 1f24a03234a6b0bb0e38a47a471ef3004ce858d0 (diff) | |
download | haskell-edff1efa74edcfa9db0010ae92e1e159ecb60b7e.tar.gz |
Disable package auto-hiding if -hide-all-packages is passed
Summary:
This is in preparation for thinning/renaming package arguments, which allow
users to rename modules of packages they import. In situations like this,
it may be desirable to load multiple copies of a package at different versions
explicitly under different names.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate
Reviewers: simonpj, simonmar, hvr, austin
Subscribers: simonmar, relrod, ezyang, carter
Differential Revision: https://phabricator.haskell.org/D106
-rw-r--r-- | compiler/main/Packages.lhs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/compiler/main/Packages.lhs b/compiler/main/Packages.lhs index c240956e4d..5973bc5d4b 100644 --- a/compiler/main/Packages.lhs +++ b/compiler/main/Packages.lhs @@ -78,12 +78,18 @@ import qualified Data.Set as Set -- provide. -- -- The package state is computed by 'initPackages', and kept in DynFlags. +-- It is influenced by various package flags: -- --- * @-package <pkg>@ causes @<pkg>@ to become exposed, and all other packages --- with the same name to become hidden. +-- * @-package <pkg>@ and @-package-id <pkg>@ cause @<pkg>@ to become exposed. +-- If @-hide-all-packages@ was not specified, these commands also cause +-- all other packages with the same name to become hidden. -- -- * @-hide-package <pkg>@ causes @<pkg>@ to become hidden. -- +-- * (there are a few more flags, check below for their semantics) +-- +-- The package state has the following properties. +-- -- * Let @exposedPackages@ be the set of packages thus exposed. -- Let @depExposedPackages@ be the transitive closure from @exposedPackages@ of -- their dependencies. @@ -401,9 +407,12 @@ applyPackageFlag dflags unusable pkgs flag = where -- When a package is requested to be exposed, we hide all other - -- packages with the same name. + -- packages with the same name if -hide-all-packages was not specified. + -- If it was specified, we expect users to not try to expose a package + -- multiple times, so don't hide things. hideAll name ps = map maybe_hide ps where maybe_hide p + | gopt Opt_HideAllPackages dflags = p | pkgName (sourcePackageId p) == name = p {exposed=False} | otherwise = p @@ -475,10 +484,12 @@ packageFlagErr dflags flag reasons -- that is already exposed. This just makes it non-fatal to have two -- versions of a package exposed, which can happen if you install a -- later version of a package in the user database, for example. +-- However, don't do this if @-hide-all-packages@ was passed. -- hideOldPackages :: DynFlags -> [PackageConfig] -> IO [PackageConfig] hideOldPackages dflags pkgs = mapM maybe_hide pkgs where maybe_hide p + | gopt Opt_HideAllPackages dflags = return p | not (exposed p) = return p | (p' : _) <- later_versions = do debugTraceMsg dflags 2 $ |