From 35d213abfe27502fa34b60975c4b18ed51bfeb05 Mon Sep 17 00:00:00 2001 From: Simon Peyton Jones Date: Tue, 2 Aug 2011 08:18:03 +0100 Subject: 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 --- compiler/hsSyn/HsImpExp.lhs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'compiler/hsSyn/HsImpExp.lhs') 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) -- cgit v1.2.1