[project @ 2001-03-08 12:07:38 by simonpj]
[ghc-hetmet.git] / ghc / compiler / rename / RnNames.lhs
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
3 %
4 \section[RnNames]{Extracting imported and top-level names in scope}
5
6 \begin{code}
7 module RnNames (
8         getGlobalNames, exportsFromAvail
9     ) where
10
11 #include "HsVersions.h"
12
13 import CmdLineOpts      ( DynFlag(..) )
14
15 import HsSyn            ( HsModule(..), HsDecl(..), IE(..), ieName, ImportDecl(..),
16                           ForeignDecl(..), ForKind(..), isDynamicExtName,
17                           collectLocatedHsBinders
18                         )
19 import RdrHsSyn         ( RdrNameIE, RdrNameImportDecl,
20                           RdrNameHsModule, RdrNameHsDecl
21                         )
22 import RnIfaces         ( recordLocalSlurps )
23 import RnHiFiles        ( getTyClDeclBinders, loadInterface )
24 import RnEnv
25 import RnMonad
26
27 import FiniteMap
28 import PrelNames        ( pRELUDE_Name, mAIN_Name, main_RDR_Unqual, isUnboundName )
29 import Module           ( ModuleName, moduleName, WhereFrom(..) )
30 import Name             ( Name, nameSrcLoc, nameOccName )
31 import NameSet
32 import NameEnv
33 import HscTypes         ( Provenance(..), ImportReason(..), GlobalRdrEnv,
34                           GenAvailInfo(..), AvailInfo, Avails, AvailEnv, 
35                           Deprecations(..), ModIface(..)
36                         )
37 import RdrName          ( rdrNameOcc, setRdrNameOcc )
38 import OccName          ( setOccNameSpace, dataName )
39 import NameSet          ( elemNameSet, emptyNameSet )
40 import Outputable
41 import Maybes           ( maybeToBool, catMaybes, mapMaybe )
42 import ListSetOps       ( removeDups )
43 import Util             ( sortLt )
44 import List             ( partition )
45 \end{code}
46
47
48
49 %************************************************************************
50 %*                                                                      *
51 \subsection{Get global names}
52 %*                                                                      *
53 %************************************************************************
54
55 \begin{code}
56 getGlobalNames :: Module -> RdrNameHsModule
57                -> RnMG (GlobalRdrEnv,   -- Maps all in-scope things
58                         GlobalRdrEnv,   -- Maps just *local* things
59                         ExportAvails)   -- The exported stuff
60
61 getGlobalNames this_mod (HsModule _ _ _ imports decls _ mod_loc)
62   =             -- PROCESS LOCAL DECLS
63                 -- Do these *first* so that the correct provenance gets
64                 -- into the global name cache.
65         importsFromLocalDecls this_mod decls            `thenRn` \ (local_gbl_env, local_mod_avails) ->
66
67                 -- PROCESS IMPORT DECLS
68                 -- Do the non {- SOURCE -} ones first, so that we get a helpful
69                 -- warning for {- SOURCE -} ones that are unnecessary
70         doptRn Opt_NoImplicitPrelude                            `thenRn` \ opt_no_prelude -> 
71         let
72           all_imports        = mk_prel_imports opt_no_prelude ++ imports
73           (source, ordinary) = partition is_source_import all_imports
74           is_source_import (ImportDecl _ ImportByUserSource _ _ _ _) = True
75           is_source_import other                                     = False
76
77           get_imports = importsFromImportDecl this_mod_name
78         in
79         mapAndUnzipRn get_imports ordinary      `thenRn` \ (imp_gbl_envs1, imp_avails_s1) ->
80         mapAndUnzipRn get_imports source        `thenRn` \ (imp_gbl_envs2, imp_avails_s2) ->
81
82                 -- COMBINE RESULTS
83                 -- We put the local env second, so that a local provenance
84                 -- "wins", even if a module imports itself.
85         let
86             gbl_env :: GlobalRdrEnv
87             imp_gbl_env = foldr plusGlobalRdrEnv emptyRdrEnv (imp_gbl_envs2 ++ imp_gbl_envs1)
88             gbl_env     = imp_gbl_env `plusGlobalRdrEnv` local_gbl_env
89
90             all_avails :: ExportAvails
91             all_avails = foldr plusExportAvails local_mod_avails (imp_avails_s2 ++ imp_avails_s1)
92         in
93
94                 -- ALL DONE
95         returnRn (gbl_env, local_gbl_env, all_avails)
96   where
97     this_mod_name = moduleName this_mod
98
99         -- NB: opt_NoImplicitPrelude is slightly different to import Prelude ();
100         -- because the former doesn't even look at Prelude.hi for instance declarations,
101         -- whereas the latter does.
102     mk_prel_imports no_prelude
103         | this_mod_name == pRELUDE_Name ||
104           explicit_prelude_import ||
105           no_prelude
106         = []
107
108         | otherwise = [ImportDecl pRELUDE_Name
109                                   ImportByUser
110                                   False {- Not qualified -}
111                                   Nothing       {- No "as" -}
112                                   Nothing       {- No import list -}
113                                   mod_loc]
114     
115     explicit_prelude_import
116       = not (null [ () | (ImportDecl mod _ _ _ _ _) <- imports, mod == pRELUDE_Name ])
117 \end{code}
118         
119 \begin{code}
120 importsFromImportDecl :: ModuleName
121                       -> RdrNameImportDecl
122                       -> RnMG (GlobalRdrEnv, 
123                                ExportAvails) 
124
125 importsFromImportDecl this_mod_name (ImportDecl imp_mod_name from qual_only as_mod import_spec iloc)
126   = pushSrcLocRn iloc $
127
128     loadInterface (ppr imp_mod_name <+> ptext SLIT("is directly imported"))
129                   imp_mod_name from                     `thenRn` \ iface ->
130     let
131         imp_mod          = mi_module iface
132         avails_by_module = mi_exports iface
133         deprecs          = mi_deprecs iface
134
135         avails :: Avails
136         avails = [ avail | (mod_name, avails) <- avails_by_module,
137                            mod_name /= this_mod_name,
138                            avail <- avails ]
139         -- If the module exports anything defined in this module, just ignore it.
140         -- Reason: otherwise it looks as if there are two local definition sites
141         -- for the thing, and an error gets reported.  Easiest thing is just to
142         -- filter them out up front. This situation only arises if a module
143         -- imports itself, or another module that imported it.  (Necessarily,
144         -- this invoves a loop.)  
145         --
146         -- Tiresome consequence: if you say
147         --      module A where
148         --         import B( AType )
149         --         type AType = ...
150         --
151         --      module B( AType ) where
152         --         import {-# SOURCE #-} A( AType )
153         --
154         -- then you'll get a 'B does not export AType' message.  Oh well.
155
156     in
157     if null avails_by_module then
158         -- If there's an error in loadInterface, (e.g. interface
159         -- file not found) we get lots of spurious errors from 'filterImports'
160         returnRn (emptyRdrEnv, mkEmptyExportAvails imp_mod_name)
161     else
162
163         -- Complain if we import a deprecated module
164     (case deprecs of    
165         DeprecAll txt -> addWarnRn (moduleDeprec imp_mod_name txt)
166         other         -> returnRn ()
167     )                                                   `thenRn_`
168
169         -- Filter the imports according to the import list
170     filterImports imp_mod_name from import_spec avails  `thenRn` \ (filtered_avails, hides, explicits) ->
171
172     let
173         unqual_imp = not qual_only              -- Maybe want unqualified names
174         qual_mod   = case as_mod of
175                         Nothing           -> imp_mod_name
176                         Just another_name -> another_name
177
178         mk_prov name = NonLocalDef (UserImport imp_mod iloc (name `elemNameSet` explicits)) 
179         gbl_env      = mkGlobalRdrEnv qual_mod unqual_imp True hides mk_prov filtered_avails deprecs
180         exports      = mkExportAvails qual_mod unqual_imp gbl_env            filtered_avails
181     in
182     returnRn (gbl_env, exports)
183 \end{code}
184
185
186 \begin{code}
187 importsFromLocalDecls this_mod decls
188   = mapRn (getLocalDeclBinders this_mod) decls  `thenRn` \ avails_s ->
189         -- The avails that are returned don't include the "system" names
190     let
191         avails = concat avails_s
192
193         all_names :: [Name]     -- All the defns; no dups eliminated
194         all_names = [name | avail <- avails, name <- availNames avail]
195
196         dups :: [[Name]]
197         (_, dups) = removeDups compare all_names
198     in
199         -- Check for duplicate definitions
200         -- The complaint will come out as "Multiple declarations of Foo.f" because
201         -- since 'f' is in the env twice, the unQualInScope used by the error-msg
202         -- printer returns False.  It seems awkward to fix, unfortunately.
203     mapRn_ (addErrRn . dupDeclErr) dups                 `thenRn_` 
204
205
206         -- Record that locally-defined things are available
207     recordLocalSlurps (availsToNameSet avails)          `thenRn_`
208     let
209         mod_name   = moduleName this_mod
210         unqual_imp = True       -- Want unqualified names
211         mk_prov n  = LocalDef   -- Provenance is local
212         hides      = []         -- Hide nothing
213
214         gbl_env    = mkGlobalRdrEnv mod_name unqual_imp True hides mk_prov avails NoDeprecs
215             -- NoDeprecs: don't complain about locally defined names
216             -- For a start, we may be exporting a deprecated thing
217             -- Also we may use a deprecated thing in the defn of another
218             -- deprecated things.  We may even use a deprecated thing in
219             -- the defn of a non-deprecated thing, when changing a module's 
220             -- interface
221
222         exports    = mkExportAvails mod_name unqual_imp gbl_env            avails
223     in
224     returnRn (gbl_env, exports)
225
226 ---------------------------
227 getLocalDeclBinders :: Module -> RdrNameHsDecl -> RnMG [AvailInfo]
228 getLocalDeclBinders mod (TyClD tycl_decl)
229   =     -- For type and class decls, we generate Global names, with
230         -- no export indicator.  They need to be global because they get
231         -- permanently bound into the TyCons and Classes.  They don't need
232         -- an export indicator because they are all implicitly exported.
233     getTyClDeclBinders mod tycl_decl    `thenRn` \ (avail, sys_names) ->
234
235         -- Record that the system names are available
236     recordLocalSlurps (mkNameSet sys_names)     `thenRn_`
237     returnRn [avail]
238
239 getLocalDeclBinders mod (ValD binds)
240   = mapRn new (collectLocatedHsBinders binds)           `thenRn` \ avails ->
241     returnRn avails
242   where
243     new (rdr_name, loc) = newTopBinder mod rdr_name loc         `thenRn` \ name ->
244                           returnRn (Avail name)
245
246 getLocalDeclBinders mod (ForD (ForeignDecl nm kind _ ext_nm _ loc))
247   | binds_haskell_name kind
248   = newTopBinder mod nm loc         `thenRn` \ name ->
249     returnRn [Avail name]
250
251   | otherwise           -- a foreign export
252   = returnRn []
253   where
254     binds_haskell_name (FoImport _) = True
255     binds_haskell_name FoLabel      = True
256     binds_haskell_name FoExport     = isDynamicExtName ext_nm
257
258 getLocalDeclBinders mod (FixD _)    = returnRn []
259 getLocalDeclBinders mod (DeprecD _) = returnRn []
260 getLocalDeclBinders mod (DefD _)    = returnRn []
261 getLocalDeclBinders mod (InstD _)   = returnRn []
262 getLocalDeclBinders mod (RuleD _)   = returnRn []
263 \end{code}
264
265
266 %************************************************************************
267 %*                                                                      *
268 \subsection{Filtering imports}
269 %*                                                                      *
270 %************************************************************************
271
272 @filterImports@ takes the @ExportEnv@ telling what the imported module makes
273 available, and filters it through the import spec (if any).
274
275 \begin{code}
276 filterImports :: ModuleName                     -- The module being imported
277               -> WhereFrom                      -- Tells whether it's a {-# SOURCE #-} import
278               -> Maybe (Bool, [RdrNameIE])      -- Import spec; True => hiding
279               -> [AvailInfo]                    -- What's available
280               -> RnMG ([AvailInfo],             -- What's actually imported
281                        [AvailInfo],             -- What's to be hidden
282                                                 -- (the unqualified version, that is)
283                         -- (We need to return both the above sets, because
284                         --  the qualified version is never hidden; so we can't
285                         --  implement hiding by reducing what's imported.)
286                        NameSet)                 -- What was imported explicitly
287
288         -- Complains if import spec mentions things that the module doesn't export
289         -- Warns/informs if import spec contains duplicates.
290 filterImports mod from Nothing imports
291   = returnRn (imports, [], emptyNameSet)
292
293 filterImports mod from (Just (want_hiding, import_items)) total_avails
294   = flatMapRn get_item import_items             `thenRn` \ avails_w_explicits ->
295     let
296         (item_avails, explicits_s) = unzip avails_w_explicits
297         explicits                  = foldl addListToNameSet emptyNameSet explicits_s
298     in
299     if want_hiding 
300     then        
301         -- All imported; item_avails to be hidden
302         returnRn (total_avails, item_avails, emptyNameSet)
303     else
304         -- Just item_avails imported; nothing to be hidden
305         returnRn (item_avails, [], explicits)
306   where
307     import_fm :: FiniteMap OccName AvailInfo
308     import_fm = listToFM [ (nameOccName name, avail) 
309                          | avail <- total_avails,
310                            name  <- availNames avail]
311         -- Even though availNames returns data constructors too,
312         -- they won't make any difference because naked entities like T
313         -- in an import list map to TcOccs, not VarOccs.
314
315     bale_out item = addErrRn (badImportItemErr mod from item)   `thenRn_`
316                     returnRn []
317
318     get_item item@(IEModuleContents _) = bale_out item
319
320     get_item item@(IEThingAll _)
321       = case check_item item of
322           Nothing                    -> bale_out item
323           Just avail@(AvailTC _ [n]) ->         -- This occurs when you import T(..), but
324                                                 -- only export T abstractly.  The single [n]
325                                                 -- in the AvailTC is the type or class itself
326                                         addWarnRn (dodgyImportWarn mod item)    `thenRn_`
327                                         returnRn [(avail, [availName avail])]
328           Just avail                 -> returnRn [(avail, [availName avail])]
329
330     get_item item@(IEThingAbs n)
331       | want_hiding     -- hiding( C ) 
332                         -- Here the 'C' can be a data constructor *or* a type/class
333       = case catMaybes [check_item item, check_item (IEThingAbs data_n)] of
334                 []     -> bale_out item
335                 avails -> returnRn [(a, []) | a <- avails]
336                                 -- The 'explicits' list is irrelevant when hiding
337       where
338         data_n = setRdrNameOcc n (setOccNameSpace (rdrNameOcc n) dataName)
339
340     get_item item
341       = case check_item item of
342           Nothing    -> bale_out item
343           Just avail -> returnRn [(avail, availNames avail)]
344
345     check_item item
346       | not (maybeToBool maybe_in_import_avails) ||
347         not (maybeToBool maybe_filtered_avail)
348       = Nothing
349
350       | otherwise    
351       = Just filtered_avail
352                 
353       where
354         wanted_occ             = rdrNameOcc (ieName item)
355         maybe_in_import_avails = lookupFM import_fm wanted_occ
356
357         Just avail             = maybe_in_import_avails
358         maybe_filtered_avail   = filterAvail item avail
359         Just filtered_avail    = maybe_filtered_avail
360 \end{code}
361
362
363
364 %************************************************************************
365 %*                                                                      *
366 \subsection{Qualifiying imports}
367 %*                                                                      *
368 %************************************************************************
369
370 \begin{code}
371 mkEmptyExportAvails :: ModuleName -> ExportAvails
372 mkEmptyExportAvails mod_name = (unitFM mod_name [], emptyNameEnv)
373
374 mkExportAvails :: ModuleName -> Bool -> GlobalRdrEnv -> [AvailInfo] -> ExportAvails
375 mkExportAvails mod_name unqual_imp gbl_env avails
376   = (mod_avail_env, entity_avail_env)
377   where
378     mod_avail_env = unitFM mod_name unqual_avails 
379
380         -- unqual_avails is the Avails that are visible in *unqualfied* form
381         -- (1.4 Report, Section 5.1.1)
382         -- For example, in 
383         --      import T hiding( f )
384         -- we delete f from avails
385
386     unqual_avails | not unqual_imp = [] -- Short cut when no unqualified imports
387                   | otherwise      = mapMaybe prune avails
388
389     prune (Avail n) | unqual_in_scope n = Just (Avail n)
390     prune (Avail n) | otherwise         = Nothing
391     prune (AvailTC n ns) | null uqs     = Nothing
392                          | otherwise    = Just (AvailTC n uqs)
393                          where
394                            uqs = filter unqual_in_scope ns
395
396     unqual_in_scope n = unQualInScope gbl_env n
397
398     entity_avail_env = mkNameEnv [ (name,avail) | avail <- avails, 
399                                                   name  <- availNames avail]
400
401 plusExportAvails ::  ExportAvails ->  ExportAvails ->  ExportAvails
402 plusExportAvails (m1, e1) (m2, e2)
403   = (plusFM_C (++) m1 m2, plusAvailEnv e1 e2)
404         -- ToDo: wasteful: we do this once for each constructor!
405 \end{code}
406
407
408 %************************************************************************
409 %*                                                                      *
410 \subsection{Export list processing}
411 %*                                                                      *
412 %************************************************************************
413
414 Processing the export list.
415
416 You might think that we should record things that appear in the export list
417 as ``occurrences'' (using @addOccurrenceName@), but you'd be wrong.
418 We do check (here) that they are in scope,
419 but there is no need to slurp in their actual declaration
420 (which is what @addOccurrenceName@ forces).
421
422 Indeed, doing so would big trouble when
423 compiling @PrelBase@, because it re-exports @GHC@, which includes @takeMVar#@,
424 whose type includes @ConcBase.StateAndSynchVar#@, and so on...
425
426 \begin{code}
427 type ExportAccum        -- The type of the accumulating parameter of
428                         -- the main worker function in exportsFromAvail
429      = ([ModuleName],           -- 'module M's seen so far
430         ExportOccMap,           -- Tracks exported occurrence names
431         AvailEnv)               -- The accumulated exported stuff, kept in an env
432                                 --   so we can common-up related AvailInfos
433
434 type ExportOccMap = FiniteMap OccName (Name, RdrNameIE)
435         -- Tracks what a particular exported OccName
436         --   in an export list refers to, and which item
437         --   it came from.  It's illegal to export two distinct things
438         --   that have the same occurrence name
439
440
441 exportsFromAvail :: ModuleName
442                  -> Maybe [RdrNameIE]   -- Export spec
443                  -> ExportAvails
444                  -> GlobalRdrEnv 
445                  -> RnMG Avails
446         -- Complains if two distinct exports have same OccName
447         -- Warns about identical exports.
448         -- Complains about exports items not in scope
449 exportsFromAvail this_mod Nothing export_avails global_name_env
450   = exportsFromAvail this_mod true_exports export_avails global_name_env
451   where
452     true_exports = Just $ if this_mod == mAIN_Name
453                           then [IEVar main_RDR_Unqual]
454                                -- export Main.main *only* unless otherwise specified,
455                           else [IEModuleContents this_mod]
456                                -- but for all other modules export everything.
457
458 exportsFromAvail this_mod (Just export_items) 
459                  (mod_avail_env, entity_avail_env)
460                  global_name_env
461   = doptRn Opt_WarnDuplicateExports             `thenRn` \ warn_dup_exports ->
462     foldlRn (exports_from_item warn_dup_exports)
463             ([], emptyFM, emptyAvailEnv) export_items
464                                                 `thenRn` \ (_, _, export_avail_map) ->
465     let
466         export_avails :: [AvailInfo]
467         export_avails   = nameEnvElts export_avail_map
468     in
469     returnRn export_avails
470
471   where
472     exports_from_item :: Bool -> ExportAccum -> RdrNameIE -> RnMG ExportAccum
473
474     exports_from_item warn_dups acc@(mods, occs, avails) ie@(IEModuleContents mod)
475         | mod `elem` mods       -- Duplicate export of M
476         = warnCheckRn warn_dups (dupModuleExport mod)   `thenRn_`
477           returnRn acc
478
479         | otherwise
480         = case lookupFM mod_avail_env mod of
481                 Nothing         -> failWithRn acc (modExportErr mod)
482                 Just mod_avails -> foldlRn (check_occs ie) occs mod_avails
483                                    `thenRn` \ occs' ->
484                                    let
485                                         avails' = foldl addAvail avails mod_avails
486                                    in
487                                    returnRn (mod:mods, occs', avails')
488
489     exports_from_item warn_dups acc@(mods, occs, avails) ie
490         = lookupSrcName global_name_env (ieName ie)     `thenRn` \ name -> 
491
492                 -- See what's available in the current environment
493           case lookupNameEnv entity_avail_env name of {
494             Nothing ->  -- Presumably this happens because lookupSrcName didn't find
495                         -- the name and returned an unboundName, which won't be in
496                         -- the entity_avail_env, of course
497                         WARN( not (isUnboundName name), ppr name )
498                         returnRn acc ;
499
500             Just avail ->
501
502                 -- Filter out the bits we want
503           case filterAvail ie avail of {
504             Nothing ->  -- Not enough availability
505                            failWithRn acc (exportItemErr ie) ;
506
507             Just export_avail ->        
508
509                 -- Phew!  It's OK!  Now to check the occurrence stuff!
510           warnCheckRn (ok_item ie avail) (dodgyExportWarn ie)   `thenRn_`
511           check_occs ie occs export_avail                       `thenRn` \ occs' ->
512           returnRn (mods, occs', addAvail avails export_avail)
513           }}
514
515
516
517 ok_item (IEThingAll _) (AvailTC _ [n]) = False
518   -- This occurs when you import T(..), but
519   -- only export T abstractly.  The single [n]
520   -- in the AvailTC is the type or class itself
521 ok_item _ _ = True
522
523 check_occs :: RdrNameIE -> ExportOccMap -> AvailInfo -> RnMG ExportOccMap
524 check_occs ie occs avail 
525   = doptRn Opt_WarnDuplicateExports     `thenRn` \ warn_dup_exports ->
526     foldlRn (check warn_dup_exports) occs (availNames avail)
527   where
528     check warn_dup occs name
529       = case lookupFM occs name_occ of
530           Nothing           -> returnRn (addToFM occs name_occ (name, ie))
531           Just (name', ie') 
532             | name == name' ->  -- Duplicate export
533                                 warnCheckRn warn_dup
534                                             (dupExportWarn name_occ ie ie')
535                                 `thenRn_` returnRn occs
536
537             | otherwise     ->  -- Same occ name but different names: an error
538                                 failWithRn occs (exportClashErr name_occ ie ie')
539       where
540         name_occ = nameOccName name
541 \end{code}
542
543 %************************************************************************
544 %*                                                                      *
545 \subsection{Errors}
546 %*                                                                      *
547 %************************************************************************
548
549 \begin{code}
550 badImportItemErr mod from ie
551   = sep [ptext SLIT("Module"), quotes (ppr mod), source_import,
552          ptext SLIT("does not export"), quotes (ppr ie)]
553   where
554     source_import = case from of
555                       ImportByUserSource -> ptext SLIT("(hi-boot interface)")
556                       other              -> empty
557
558 dodgyImportWarn mod item = dodgyMsg (ptext SLIT("import")) item
559 dodgyExportWarn     item = dodgyMsg (ptext SLIT("export")) item
560
561 dodgyMsg kind item@(IEThingAll tc)
562   = sep [ ptext SLIT("The") <+> kind <+> ptext SLIT("item") <+> quotes (ppr item),
563           ptext SLIT("suggests that") <+> quotes (ppr tc) <+> ptext SLIT("has constructor or class methods"),
564           ptext SLIT("but it has none; it is a type synonym or abstract type or class") ]
565           
566 modExportErr mod
567   = hsep [ ptext SLIT("Unknown module in export list: module"), quotes (ppr mod)]
568
569 exportItemErr export_item
570   = sep [ ptext SLIT("The export item") <+> quotes (ppr export_item),
571           ptext SLIT("attempts to export constructors or class methods that are not visible here") ]
572
573 exportClashErr occ_name ie1 ie2
574   = hsep [ptext SLIT("The export items"), quotes (ppr ie1)
575          ,ptext SLIT("and"), quotes (ppr ie2)
576          ,ptext SLIT("create conflicting exports for"), quotes (ppr occ_name)]
577
578 dupDeclErr (n:ns)
579   = vcat [ptext SLIT("Multiple declarations of") <+> quotes (ppr n),
580           nest 4 (vcat (map ppr sorted_locs))]
581   where
582     sorted_locs = sortLt occ'ed_before (map nameSrcLoc (n:ns))
583     occ'ed_before a b = LT == compare a b
584
585 dupExportWarn occ_name ie1 ie2
586   = hsep [quotes (ppr occ_name), 
587           ptext SLIT("is exported by"), quotes (ppr ie1),
588           ptext SLIT("and"),            quotes (ppr ie2)]
589
590 dupModuleExport mod
591   = hsep [ptext SLIT("Duplicate"),
592           quotes (ptext SLIT("Module") <+> ppr mod), 
593           ptext SLIT("in export list")]
594
595 moduleDeprec mod txt
596   = sep [ ptext SLIT("Module") <+> quotes (ppr mod) <+> ptext SLIT("is deprecated:"), 
597           nest 4 (ppr txt) ]      
598 \end{code}