summaryrefslogtreecommitdiff
path: root/compiler/hsSyn/HsImpExp.lhs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2011-08-02 08:18:03 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2011-08-02 08:18:03 +0100
commit35d213abfe27502fa34b60975c4b18ed51bfeb05 (patch)
treeaab2a30ab9acbf6ab2bc51366530027eab13b8ad /compiler/hsSyn/HsImpExp.lhs
parent6059755e045ed8c4a8c3d48cc0ec5733bd950c0f (diff)
downloadhaskell-35d213abfe27502fa34b60975c4b18ed51bfeb05.tar.gz
Refactor the imports of InteractiveContext
Instead of two fields ic_toplev_scope :: [Module] ic_imports :: [ImportDecl RdrName] we now just have one ic_imports :: [InteractiveImport] with the auxiliary data type data InteractiveImport = IIDecl (ImportDecl RdrName) -- Bring the exports of a particular module -- (filtered by an import decl) into scope | IIModule Module -- Bring into scope the entire top-level envt of -- of this module, including the things imported -- into it. This makes lots of code less confusing. No change in behaviour. It's preparatory to fixing Trac #5147. While I was at I also * Cleaned up the handling of the "implicit" Prelude import by adding a ideclImplicit field to ImportDecl. This significantly reduces plumbing in the handling of the implicit Prelude import * Used record notation consistently for ImportDecl
Diffstat (limited to 'compiler/hsSyn/HsImpExp.lhs')
-rw-r--r--compiler/hsSyn/HsImpExp.lhs12
1 files changed, 10 insertions, 2 deletions
diff --git a/compiler/hsSyn/HsImpExp.lhs b/compiler/hsSyn/HsImpExp.lhs
index 9dbb4417ae..0f7ad6e678 100644
--- a/compiler/hsSyn/HsImpExp.lhs
+++ b/compiler/hsSyn/HsImpExp.lhs
@@ -38,6 +38,7 @@ data ImportDecl name
ideclSource :: Bool, -- ^ True <=> {-# SOURCE #-} import
ideclSafe :: Bool, -- ^ True => safe import
ideclQualified :: Bool, -- ^ True => qualified
+ ideclImplicit :: Bool, -- ^ True => implicit import (of Prelude)
ideclAs :: Maybe ModuleName, -- ^ as Module
ideclHiding :: Maybe (Bool, [LIE name]) -- ^ (True => hiding, names)
} deriving (Data, Typeable)
@@ -48,6 +49,7 @@ simpleImportDecl mn = ImportDecl {
ideclPkgQual = Nothing,
ideclSource = False,
ideclSafe = True,
+ ideclImplicit = False,
ideclQualified = False,
ideclAs = Nothing,
ideclHiding = Nothing
@@ -56,11 +58,17 @@ simpleImportDecl mn = ImportDecl {
\begin{code}
instance (Outputable name) => Outputable (ImportDecl name) where
- ppr (ImportDecl mod' pkg from safe qual as spec)
- = hang (hsep [ptext (sLit "import"), ppr_imp from, pp_safe safe,
+ ppr (ImportDecl { ideclName = mod', ideclPkgQual = pkg
+ , ideclSource = from, ideclSafe = safe
+ , ideclQualified = qual, ideclImplicit = implicit
+ , ideclAs = as, ideclHiding = spec })
+ = hang (hsep [ptext (sLit "import"), ppr_imp from, pp_implicit implicit, pp_safe safe,
pp_qual qual, pp_pkg pkg, ppr mod', pp_as as])
4 (pp_spec spec)
where
+ pp_implicit False = empty
+ pp_implicit True = ptext (sLit ("(implicit)"))
+
pp_pkg Nothing = empty
pp_pkg (Just p) = doubleQuotes (ftext p)