summaryrefslogtreecommitdiff
path: root/ghc
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@cs.stanford.edu>2014-08-02 13:50:00 +0100
committerEdward Z. Yang <ezyang@cs.stanford.edu>2014-08-05 03:13:40 -0700
commit207875293fea07aa90efe215369629b657d1875a (patch)
tree1dbf891a340b07dc2a385225d3b81342fe461ec1 /ghc
parent4accf60184dba550ef0cbdf70fa8e708a4007370 (diff)
downloadhaskell-207875293fea07aa90efe215369629b657d1875a.tar.gz
Thinning and renaming modules from packages on the command line.
Summary: This patch set adds support for extra syntax on -package and related arguments which allow you to thin and rename modules from a package. For example, this argument: -package "base (Data.Bool as Bam, Data.List)" adds two more modules into scope, Bam and Data.List, without adding any of base's other modules to scope. These flags are additive: so, for example, saying: -hide-all-packages -package base -package "base (Data.Bool as Bam)" will provide both the normal bindings for modules in base, as well as the module Bam. There is also a new debug flag -ddump-mod-map which prints the state of the module mapping database. H = hidden, E = exposed (so for example EH says the module in question is exported, but in a hidden package.) Module suggestions have been minorly overhauled to work better with reexports: if you have -package "base (Data.Bool as Bam)" and mispell Bam, GHC will suggest "Did you mean Bam (defined via package flags to be base:Data.Bool)"; and generally you will get more accurate information. Also, fix a bug where we suggest the -package flag when we really need the -package-key flag. NB: The renaming afforded here does *not* affect what wired in symbols GHC generates. (But it does affect implicit prelude!) ToDo: add 'hiding' functionality, to make it easier to support the alternative prelude use-case. ToDo: Cabal support Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: new tests and validate Reviewers: simonpj, simonmar, hvr, austin Subscribers: simonmar, relrod, ezyang, carter Differential Revision: https://phabricator.haskell.org/D113 GHC Trac Issues: #9375
Diffstat (limited to 'ghc')
-rw-r--r--ghc/InteractiveUI.hs12
-rw-r--r--ghc/Main.hs7
2 files changed, 8 insertions, 11 deletions
diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs
index f42d47a51d..386d4df17d 100644
--- a/ghc/InteractiveUI.hs
+++ b/ghc/InteractiveUI.hs
@@ -39,7 +39,7 @@ import HscTypes ( tyThingParent_maybe, handleFlagWarnings, getSafeMode, hsc_IC,
setInteractivePrintName )
import Module
import Name
-import Packages ( trusted, getPackageDetails, listVisibleModuleNames )
+import Packages ( trusted, getPackageDetails, listVisibleModuleNames, pprFlag )
import PprTyThing
import RdrName ( getGRE_NameQualifier_maybes )
import SrcLoc
@@ -2333,15 +2333,7 @@ showPackages = do
let pkg_flags = packageFlags dflags
liftIO $ putStrLn $ showSDoc dflags $ vcat $
text ("active package flags:"++if null pkg_flags then " none" else "")
- : map showFlag pkg_flags
- where showFlag (ExposePackage a) = text $ showArg a
- showFlag (HidePackage p) = text $ " -hide-package " ++ p
- showFlag (IgnorePackage p) = text $ " -ignore-package " ++ p
- showFlag (TrustPackage p) = text $ " -trust " ++ p
- showFlag (DistrustPackage p) = text $ " -distrust " ++ p
- showArg (PackageArg p) = " -package " ++ p
- showArg (PackageIdArg p) = " -package-id " ++ p
- showArg (PackageKeyArg p) = " -package-key " ++ p
+ : map pprFlag pkg_flags
showPaths :: GHCi ()
showPaths = do
diff --git a/ghc/Main.hs b/ghc/Main.hs
index 2bb156c5b9..70dde39824 100644
--- a/ghc/Main.hs
+++ b/ghc/Main.hs
@@ -33,7 +33,7 @@ import InteractiveUI ( interactiveUI, ghciWelcomeMsg, defaultGhciSettings )
import Config
import Constants
import HscTypes
-import Packages ( dumpPackages, simpleDumpPackages )
+import Packages ( dumpPackages, simpleDumpPackages, pprModuleMap )
import DriverPhases
import BasicTypes ( failed )
import StaticFlags
@@ -217,6 +217,11 @@ main' postLoadMode dflags0 args flagWarnings = do
when (verbosity dflags6 >= 3) $ do
liftIO $ hPutStrLn stderr ("Hsc static flags: " ++ unwords staticFlags)
+
+ when (dopt Opt_D_dump_mod_map dflags6) . liftIO $
+ printInfoForUser (dflags6 { pprCols = 200 })
+ (pkgQual dflags6) (pprModuleMap dflags6)
+
---------------- Final sanity checking -----------
liftIO $ checkOptions postLoadMode dflags6 srcs objs