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