2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
4 \section[RnNames]{Extracting imported and top-level names in scope}
11 #include "HsVersions.h"
13 import CmdLineOpts ( opt_NoImplicitPrelude, opt_WarnDuplicateExports,
14 opt_SourceUnchanged, opt_WarnUnusedBinds
17 import HsSyn ( HsModule(..), HsDecl(..), TyClDecl(..),
19 ForeignDecl(..), ForKind(..), isDynamicExtName,
20 FixitySig(..), Sig(..), ImportDecl(..),
23 import RdrHsSyn ( RdrNameIE, RdrNameImportDecl,
24 RdrNameHsModule, RdrNameHsDecl
26 import RnIfaces ( getInterfaceExports, getDeclBinders, getDeclSysBinders,
27 recordSlurp, checkUpToDate
34 import PrelInfo ( main_RDR )
35 import UniqFM ( lookupUFM )
36 import Bag ( bagToList )
37 import Module ( ModuleName, mkThisModule, pprModuleName, WhereFrom(..) )
39 import Name ( Name, ExportFlag(..), ImportReason(..), Provenance(..),
40 isLocallyDefined, setNameProvenance,
41 nameOccName, getSrcLoc, pprProvenance, getNameProvenance
43 import RdrName ( RdrName, rdrNameOcc, setRdrNameOcc, mkRdrQual, mkRdrUnqual, isQual )
44 import OccName ( setOccNameSpace, dataName )
45 import SrcLoc ( SrcLoc )
46 import NameSet ( elemNameSet, emptyNameSet )
48 import Maybes ( maybeToBool, catMaybes, mapMaybe )
49 import UniqFM ( emptyUFM, listToUFM, plusUFM_C )
50 import Unique ( getUnique )
51 import Util ( removeDups, equivClassesByUniq, sortLt )
52 import List ( partition )
57 %************************************************************************
59 \subsection{Get global names}
61 %************************************************************************
64 getGlobalNames :: RdrNameHsModule
65 -> RnMG (Maybe (ExportEnv,
67 FixityEnv, -- Fixities for local decls only
68 AvailEnv -- Maps a name to its parent AvailInfo
69 -- Just for in-scope things only
71 -- Nothing => no need to recompile
73 getGlobalNames (HsModule this_mod _ exports imports decls _ mod_loc)
74 = -- These two fix-loops are to get the right
75 -- provenance information into a Name
76 fixRn (\ ~(rec_gbl_env, rec_exported_avails, _) ->
79 rec_unqual_fn :: Name -> Bool -- Is this chap in scope unqualified?
80 rec_unqual_fn = unQualInScope rec_gbl_env
82 rec_exp_fn :: Name -> ExportFlag
83 rec_exp_fn = mk_export_fn (availsToNameSet rec_exported_avails)
85 setModuleRn this_mod $
87 -- PROCESS LOCAL DECLS
88 -- Do these *first* so that the correct provenance gets
89 -- into the global name cache.
90 importsFromLocalDecls this_mod rec_exp_fn decls
91 `thenRn` \ (local_gbl_env, local_mod_avails) ->
93 -- PROCESS IMPORT DECLS
94 -- Do the non {- SOURCE -} ones first, so that we get a helpful
95 -- warning for {- SOURCE -} ones that are unnecessary
97 (source, ordinary) = partition is_source_import all_imports
98 is_source_import (ImportDecl _ ImportByUserSource _ _ _ _) = True
99 is_source_import other = False
101 mapAndUnzipRn (importsFromImportDecl rec_unqual_fn) ordinary
102 `thenRn` \ (imp_gbl_envs1, imp_avails_s1) ->
103 mapAndUnzipRn (importsFromImportDecl rec_unqual_fn) source
104 `thenRn` \ (imp_gbl_envs2, imp_avails_s2) ->
107 -- We put the local env second, so that a local provenance
108 -- "wins", even if a module imports itself.
110 gbl_env :: GlobalRdrEnv
111 imp_gbl_env = foldr plusGlobalRdrEnv emptyRdrEnv (imp_gbl_envs2 ++ imp_gbl_envs1)
112 gbl_env = imp_gbl_env `plusGlobalRdrEnv` local_gbl_env
114 all_avails :: ExportAvails
115 all_avails = foldr plusExportAvails local_mod_avails (imp_avails_s2 ++ imp_avails_s1)
118 -- TRY FOR EARLY EXIT
119 -- We can't go for an early exit before this because we have to check
120 -- for name clashes. Consider:
122 -- module A where module B where
126 -- Suppose I've compiled everything up, and then I add a
127 -- new definition to module B, that defines "f".
129 -- Then I must detect the name clash in A before going for an early
130 -- exit. The early-exit code checks what's actually needed from B
131 -- to compile A, and of course that doesn't include B.f. That's
132 -- why we wait till after the plusEnv stuff to do the early-exit.
133 checkEarlyExit this_mod `thenRn` \ up_to_date ->
135 returnRn (gbl_env, junk_exp_fn, Nothing)
138 -- RECORD BETTER PROVENANCES IN THE CACHE
139 -- The names in the envirnoment have better provenances (e.g. imported on line x)
140 -- than the names in the name cache. We update the latter now, so that we
141 -- we start renaming declarations we'll get the good names
142 -- The isQual is because the qualified name is always in scope
143 updateProvenances (concat [names | (rdr_name, names) <- rdrEnvToList imp_gbl_env,
144 isQual rdr_name]) `thenRn_`
146 -- PROCESS EXPORT LISTS
147 exportsFromAvail this_mod exports all_avails gbl_env `thenRn` \ exported_avails ->
150 returnRn (gbl_env, exported_avails, Just all_avails)
151 ) `thenRn` \ (gbl_env, exported_avails, maybe_stuff) ->
153 case maybe_stuff of {
154 Nothing -> returnRn Nothing ;
157 -- DEAL WITH FIXITIES
158 fixitiesFromLocalDecls gbl_env decls `thenRn` \ local_fixity_env ->
160 -- Export only those fixities that are for names that are
161 -- (a) defined in this module
163 exported_fixities :: [(Name,Fixity)]
164 exported_fixities = [(name,fixity)
165 | FixitySig name fixity _ <- nameEnvElts local_fixity_env,
166 isLocallyDefined name
170 export_mods = case exports of
172 Just es -> [mod | IEModuleContents mod <- es, mod /= this_mod]
174 export_env = ExportEnv exported_avails exported_fixities export_mods
175 (_, global_avail_env) = all_avails
177 traceRn (text "fixity env" <+> vcat (map ppr (nameEnvElts local_fixity_env))) `thenRn_`
179 returnRn (Just (export_env, gbl_env, local_fixity_env, global_avail_env))
182 junk_exp_fn = error "RnNames:export_fn"
184 all_imports = prel_imports ++ imports
186 -- NB: opt_NoImplicitPrelude is slightly different to import Prelude ();
187 -- because the former doesn't even look at Prelude.hi for instance declarations,
188 -- whereas the latter does.
189 prel_imports | this_mod == pRELUDE_Name ||
190 explicit_prelude_import ||
191 opt_NoImplicitPrelude
194 | otherwise = [ImportDecl pRELUDE_Name
196 False {- Not qualified -}
197 Nothing {- No "as" -}
198 Nothing {- No import list -}
201 explicit_prelude_import
202 = not (null [ () | (ImportDecl mod _ _ _ _ _) <- imports, mod == pRELUDE_Name ])
207 = checkErrsRn `thenRn` \ no_errs_so_far ->
208 if not no_errs_so_far then
209 -- Found errors already, so exit now
213 traceRn (text "Considering whether compilation is required...") `thenRn_`
214 if not opt_SourceUnchanged then
215 -- Source code changed and no errors yet... carry on
216 traceRn (nest 4 (text "source file changed or recompilation check turned off")) `thenRn_`
220 -- Unchanged source, and no errors yet; see if usage info
221 -- up to date, and exit if so
222 checkUpToDate mod `thenRn` \ up_to_date ->
224 then putDocRn (text "Compilation IS NOT required")
225 else returnRn ()) `thenRn_`
230 importsFromImportDecl :: (Name -> Bool) -- OK to omit qualifier
232 -> RnMG (GlobalRdrEnv,
235 importsFromImportDecl is_unqual (ImportDecl imp_mod_name from qual_only as_mod import_spec iloc)
236 = pushSrcLocRn iloc $
237 getInterfaceExports imp_mod_name from `thenRn` \ (imp_mod, avails) ->
240 -- If there's an error in getInterfaceExports, (e.g. interface
241 -- file not found) we get lots of spurious errors from 'filterImports'
242 returnRn (emptyRdrEnv, mkEmptyExportAvails imp_mod_name)
245 filterImports imp_mod_name import_spec avails `thenRn` \ (filtered_avails, hides, explicits) ->
247 qualifyImports imp_mod_name
248 (not qual_only) -- Maybe want unqualified names
250 (improveAvails imp_mod iloc explicits
251 is_unqual filtered_avails)
254 improveAvails imp_mod iloc explicits is_unqual avails
255 -- We 'improve' the provenance by setting
256 -- (a) the import-reason field, so that the Name says how it came into scope
257 -- including whether it's explicitly imported
258 -- (b) the print-unqualified field
259 = map improve_avail avails
261 improve_avail (Avail n) = Avail (improve n)
262 improve_avail (AvailTC n ns) = AvailTC (improve n) (map improve ns)
264 improve name = setNameProvenance name
265 (NonLocalDef (UserImport imp_mod iloc (is_explicit name))
267 is_explicit name = name `elemNameSet` explicits
272 importsFromLocalDecls mod_name rec_exp_fn decls
273 = mapRn (getLocalDeclBinders newLocalName) decls `thenRn` \ avails_s ->
276 avails = concat avails_s
278 all_names :: [Name] -- All the defns; no dups eliminated
279 all_names = [name | avail <- avails, name <- availNames avail]
282 (_, dups) = removeDups compare all_names
284 -- Check for duplicate definitions
285 mapRn_ (addErrRn . dupDeclErr) dups `thenRn_`
287 -- Record that locally-defined things are available
288 mapRn_ (recordSlurp Nothing) avails `thenRn_`
290 -- Build the environment
291 qualifyImports mod_name
292 True -- Want unqualified names
298 mod = mkThisModule mod_name
300 newLocalName rdr_name loc
301 = (if isQual rdr_name then
302 qualNameErr (text "the binding for" <+> quotes (ppr rdr_name)) (rdr_name,loc)
303 -- There should never be a qualified name in a binding position (except in instance decls)
304 -- The parser doesn't check this because the same parser parses instance decls
306 returnRn ()) `thenRn_`
308 newLocalTopBinder mod (rdrNameOcc rdr_name) rec_exp_fn loc
311 getLocalDeclBinders :: (RdrName -> SrcLoc -> RnMG Name) -- New-name function
314 getLocalDeclBinders new_name (ValD binds)
315 = mapRn do_one (bagToList (collectTopBinders binds))
317 do_one (rdr_name, loc) = new_name rdr_name loc `thenRn` \ name ->
318 returnRn (Avail name)
320 getLocalDeclBinders new_name decl
321 = getDeclBinders new_name decl `thenRn` \ maybe_avail ->
323 Nothing -> returnRn [] -- Instance decls and suchlike
324 Just avail -> getDeclSysBinders new_sys_name decl `thenRn_`
327 -- The getDeclSysBinders is just to get the names of superclass selectors
328 -- etc, into the cache
329 new_sys_name rdr_name loc = newImplicitBinder (rdrNameOcc rdr_name) loc
331 fixitiesFromLocalDecls :: GlobalRdrEnv -> [RdrNameHsDecl] -> RnMG FixityEnv
332 fixitiesFromLocalDecls gbl_env decls
333 = foldlRn getFixities emptyNameEnv decls
335 getFixities :: FixityEnv -> RdrNameHsDecl -> RnMG FixityEnv
336 getFixities acc (FixD fix)
339 getFixities acc (TyClD (ClassDecl _ _ _ _ sigs _ _ _ _ _ _ _))
340 = foldlRn fix_decl acc [sig | FixSig sig <- sigs]
341 -- Get fixities from class decl sigs too.
342 getFixities acc other_decl
345 fix_decl acc sig@(FixitySig rdr_name fixity loc)
346 = -- Check for fixity decl for something not declared
347 case lookupRdrEnv gbl_env rdr_name of {
348 Nothing | opt_WarnUnusedBinds
349 -> pushSrcLocRn loc (addWarnRn (unusedFixityDecl rdr_name fixity))
350 `thenRn_` returnRn acc
351 | otherwise -> returnRn acc ;
355 -- Check for duplicate fixity decl
356 case lookupNameEnv acc name of {
357 Just (FixitySig _ _ loc') -> addErrRn (dupFixityDecl rdr_name loc loc')
358 `thenRn_` returnRn acc ;
360 Nothing -> returnRn (addToNameEnv acc name (FixitySig name fixity loc))
364 %************************************************************************
366 \subsection{Filtering imports}
368 %************************************************************************
370 @filterImports@ takes the @ExportEnv@ telling what the imported module makes
371 available, and filters it through the import spec (if any).
374 filterImports :: ModuleName -- The module being imported
375 -> Maybe (Bool, [RdrNameIE]) -- Import spec; True => hiding
376 -> [AvailInfo] -- What's available
377 -> RnMG ([AvailInfo], -- What's actually imported
378 [AvailInfo], -- What's to be hidden
379 -- (the unqualified version, that is)
380 -- (We need to return both the above sets, because
381 -- the qualified version is never hidden; so we can't
382 -- implement hiding by reducing what's imported.)
383 NameSet) -- What was imported explicitly
385 -- Complains if import spec mentions things that the module doesn't export
386 -- Warns/informs if import spec contains duplicates.
387 filterImports mod Nothing imports
388 = returnRn (imports, [], emptyNameSet)
390 filterImports mod (Just (want_hiding, import_items)) avails
391 = flatMapRn get_item import_items `thenRn` \ avails_w_explicits ->
393 (item_avails, explicits_s) = unzip avails_w_explicits
394 explicits = foldl addListToNameSet emptyNameSet explicits_s
398 -- All imported; item_avails to be hidden
399 returnRn (avails, item_avails, emptyNameSet)
401 -- Just item_avails imported; nothing to be hidden
402 returnRn (item_avails, [], explicits)
404 import_fm :: FiniteMap OccName AvailInfo
405 import_fm = listToFM [ (nameOccName name, avail)
407 name <- availNames avail]
408 -- Even though availNames returns data constructors too,
409 -- they won't make any difference because naked entities like T
410 -- in an import list map to TcOccs, not VarOccs.
412 bale_out item = addErrRn (badImportItemErr mod item) `thenRn_`
415 get_item item@(IEModuleContents _) = bale_out item
417 get_item item@(IEThingAll _)
418 = case check_item item of
419 Nothing -> bale_out item
420 Just avail@(AvailTC _ [n]) -> -- This occurs when you import T(..), but
421 -- only export T abstractly. The single [n]
422 -- in the AvailTC is the type or class itself
423 addWarnRn (dodgyImportWarn mod item) `thenRn_`
424 returnRn [(avail, [availName avail])]
425 Just avail -> returnRn [(avail, [availName avail])]
427 get_item item@(IEThingAbs n)
428 | want_hiding -- hiding( C )
429 -- Here the 'C' can be a data constructor *or* a type/class
430 = case catMaybes [check_item item, check_item (IEThingAbs data_n)] of
432 avails -> returnRn [(a, []) | a <- avails]
433 -- The 'explicits' list is irrelevant when hiding
435 data_n = setRdrNameOcc n (setOccNameSpace (rdrNameOcc n) dataName)
438 = case check_item item of
439 Nothing -> bale_out item
440 Just avail -> returnRn [(avail, availNames avail)]
443 | not (maybeToBool maybe_in_import_avails) ||
444 not (maybeToBool maybe_filtered_avail)
448 = Just filtered_avail
451 wanted_occ = rdrNameOcc (ieName item)
452 maybe_in_import_avails = lookupFM import_fm wanted_occ
454 Just avail = maybe_in_import_avails
455 maybe_filtered_avail = filterAvail item avail
456 Just filtered_avail = maybe_filtered_avail
461 %************************************************************************
463 \subsection{Qualifiying imports}
465 %************************************************************************
467 @qualifyImports@ takes the @ExportEnv@ after filtering through the import spec
468 of an import decl, and deals with producing an @RnEnv@ with the
469 right qualified names. It also turns the @Names@ in the @ExportEnv@ into
470 fully fledged @Names@.
473 qualifyImports :: ModuleName -- Imported module
474 -> Bool -- True <=> want unqualified import
475 -> Maybe ModuleName -- Optional "as M" part
476 -> [AvailInfo] -- What's to be hidden
477 -> Avails -- Whats imported and how
478 -> RnMG (GlobalRdrEnv, ExportAvails)
480 qualifyImports this_mod unqual_imp as_mod hides avails
482 -- Make the name environment. We're talking about a
483 -- single module here, so there must be no name clashes.
484 -- In practice there only ever will be if it's the module
487 -- Add the things that are available
488 name_env1 = foldl add_avail emptyRdrEnv avails
490 -- Delete things that are hidden
491 name_env2 = foldl del_avail name_env1 hides
493 -- Create the export-availability info
494 export_avails = mkExportAvails qual_mod unqual_imp name_env2 avails
496 returnRn (name_env2, export_avails)
499 qual_mod = case as_mod of
501 Just another_name -> another_name
503 add_avail :: GlobalRdrEnv -> AvailInfo -> GlobalRdrEnv
504 add_avail env avail = foldl add_name env (availNames avail)
510 env1 = addOneToGlobalRdrEnv env (mkRdrQual qual_mod occ) name
511 env2 = addOneToGlobalRdrEnv env1 (mkRdrUnqual occ) name
512 occ = nameOccName name
514 del_avail env avail = foldl delOneFromGlobalRdrEnv env rdr_names
516 rdr_names = map (mkRdrUnqual . nameOccName) (availNames avail)
519 mkEmptyExportAvails :: ModuleName -> ExportAvails
520 mkEmptyExportAvails mod_name = (unitFM mod_name [], emptyUFM)
522 mkExportAvails :: ModuleName -> Bool -> GlobalRdrEnv -> [AvailInfo] -> ExportAvails
523 mkExportAvails mod_name unqual_imp name_env avails
524 = (mod_avail_env, entity_avail_env)
526 mod_avail_env = unitFM mod_name unqual_avails
528 -- unqual_avails is the Avails that are visible in *unqualfied* form
529 -- (1.4 Report, Section 5.1.1)
531 -- import T hiding( f )
532 -- we delete f from avails
534 unqual_avails | not unqual_imp = [] -- Short cut when no unqualified imports
535 | otherwise = mapMaybe prune avails
537 prune (Avail n) | unqual_in_scope n = Just (Avail n)
538 prune (Avail n) | otherwise = Nothing
539 prune (AvailTC n ns) | null uqs = Nothing
540 | otherwise = Just (AvailTC n uqs)
542 uqs = filter unqual_in_scope ns
544 unqual_in_scope n = unQualInScope name_env n
546 entity_avail_env = listToUFM [ (name,avail) | avail <- avails,
547 name <- availNames avail]
549 plusExportAvails :: ExportAvails -> ExportAvails -> ExportAvails
550 plusExportAvails (m1, e1) (m2, e2)
551 = (plusFM_C (++) m1 m2, plusAvailEnv e1 e2)
552 -- ToDo: wasteful: we do this once for each constructor!
556 %************************************************************************
558 \subsection{Export list processing}
560 %************************************************************************
562 Processing the export list.
564 You might think that we should record things that appear in the export list
565 as ``occurrences'' (using @addOccurrenceName@), but you'd be wrong.
566 We do check (here) that they are in scope,
567 but there is no need to slurp in their actual declaration
568 (which is what @addOccurrenceName@ forces).
570 Indeed, doing so would big trouble when
571 compiling @PrelBase@, because it re-exports @GHC@, which includes @takeMVar#@,
572 whose type includes @ConcBase.StateAndSynchVar#@, and so on...
575 type ExportAccum -- The type of the accumulating parameter of
576 -- the main worker function in exportsFromAvail
577 = ([ModuleName], -- 'module M's seen so far
578 ExportOccMap, -- Tracks exported occurrence names
579 AvailEnv) -- The accumulated exported stuff, kept in an env
580 -- so we can common-up related AvailInfos
582 type ExportOccMap = FiniteMap OccName (Name, RdrNameIE)
583 -- Tracks what a particular exported OccName
584 -- in an export list refers to, and which item
585 -- it came from. It's illegal to export two distinct things
586 -- that have the same occurrence name
589 exportsFromAvail :: ModuleName
590 -> Maybe [RdrNameIE] -- Export spec
594 -- Complains if two distinct exports have same OccName
595 -- Warns about identical exports.
596 -- Complains about exports items not in scope
597 exportsFromAvail this_mod Nothing export_avails global_name_env
598 = exportsFromAvail this_mod true_exports export_avails global_name_env
600 true_exports = Just $ if this_mod == mAIN_Name
601 then [IEVar main_RDR]
602 -- export Main.main *only* unless otherwise specified,
603 else [IEModuleContents this_mod]
604 -- but for all other modules export everything.
606 exportsFromAvail this_mod (Just export_items)
607 (mod_avail_env, entity_avail_env)
609 = foldlRn exports_from_item
610 ([], emptyFM, emptyAvailEnv) export_items `thenRn` \ (_, _, export_avail_map) ->
612 export_avails :: [AvailInfo]
613 export_avails = nameEnvElts export_avail_map
615 returnRn export_avails
618 exports_from_item :: ExportAccum -> RdrNameIE -> RnMG ExportAccum
620 exports_from_item acc@(mods, occs, avails) ie@(IEModuleContents mod)
621 | mod `elem` mods -- Duplicate export of M
622 = warnCheckRn opt_WarnDuplicateExports
623 (dupModuleExport mod) `thenRn_`
627 = case lookupFM mod_avail_env mod of
628 Nothing -> failWithRn acc (modExportErr mod)
629 Just mod_avails -> foldlRn (check_occs ie) occs mod_avails
632 avails' = foldl addAvail avails mod_avails
634 returnRn (mod:mods, occs', avails')
636 exports_from_item acc@(mods, occs, avails) ie
637 | not (maybeToBool maybe_in_scope)
638 = failWithRn acc (unknownNameErr (ieName ie))
640 | not (null dup_names)
641 = addNameClashErrRn rdr_name (name:dup_names) `thenRn_`
645 -- I can't see why this should ever happen; if the thing is in scope
646 -- at all it ought to have some availability
647 | not (maybeToBool maybe_avail)
648 = pprTrace "exportsFromAvail: curious Nothing:" (ppr name)
653 = failWithRn acc (exportItemErr ie)
655 | otherwise -- Phew! It's OK! Now to check the occurrence stuff!
658 = warnCheckRn (ok_item ie avail) (dodgyExportWarn ie) `thenRn_`
659 check_occs ie occs export_avail `thenRn` \ occs' ->
660 returnRn (mods, occs', addAvail avails export_avail)
664 maybe_in_scope = lookupFM global_name_env rdr_name
665 Just (name:dup_names) = maybe_in_scope
666 maybe_avail = lookupUFM entity_avail_env name
667 Just avail = maybe_avail
668 maybe_export_avail = filterAvail ie avail
669 enough_avail = maybeToBool maybe_export_avail
670 Just export_avail = maybe_export_avail
672 ok_item (IEThingAll _) (AvailTC _ [n]) = False
673 -- This occurs when you import T(..), but
674 -- only export T abstractly. The single [n]
675 -- in the AvailTC is the type or class itself
678 check_occs :: RdrNameIE -> ExportOccMap -> AvailInfo -> RnMG ExportOccMap
679 check_occs ie occs avail
680 = foldlRn check occs (availNames avail)
683 = case lookupFM occs name_occ of
684 Nothing -> returnRn (addToFM occs name_occ (name, ie))
686 | name == name' -> -- Duplicate export
687 warnCheckRn opt_WarnDuplicateExports
688 (dupExportWarn name_occ ie ie')
689 `thenRn_` returnRn occs
691 | otherwise -> -- Same occ name but different names: an error
692 failWithRn occs (exportClashErr name_occ ie ie')
694 name_occ = nameOccName name
696 mk_export_fn :: NameSet -> (Name -> ExportFlag)
697 mk_export_fn exported_names
698 = \name -> if name `elemNameSet` exported_names
703 %************************************************************************
707 %************************************************************************
710 badImportItemErr mod ie
711 = sep [ptext SLIT("Module"), quotes (pprModuleName mod),
712 ptext SLIT("does not export"), quotes (ppr ie)]
714 dodgyImportWarn mod item = dodgyMsg (ptext SLIT("import")) item
715 dodgyExportWarn item = dodgyMsg (ptext SLIT("export")) item
717 dodgyMsg kind item@(IEThingAll tc)
718 = sep [ ptext SLIT("The") <+> kind <+> ptext SLIT("item") <+> quotes (ppr item),
719 ptext SLIT("suggests that") <+> quotes (ppr tc) <+> ptext SLIT("has constructor or class methods"),
720 ptext SLIT("but it has none; it is a type synonym or abstract type or class") ]
723 = hsep [ ptext SLIT("Unknown module in export list: module"), quotes (pprModuleName mod)]
725 exportItemErr export_item
726 = sep [ ptext SLIT("The export item") <+> quotes (ppr export_item),
727 ptext SLIT("attempts to export constructors or class methods that are not visible here") ]
729 exportClashErr occ_name ie1 ie2
730 = hsep [ptext SLIT("The export items"), quotes (ppr ie1)
731 ,ptext SLIT("and"), quotes (ppr ie2)
732 ,ptext SLIT("create conflicting exports for"), quotes (ppr occ_name)]
735 = vcat [ptext SLIT("Multiple declarations of") <+> quotes (ppr n),
736 nest 4 (vcat (map pp sorted_ns))]
738 sorted_ns = sortLt occ'ed_before (n:ns)
740 occ'ed_before a b = LT == compare (getSrcLoc a) (getSrcLoc b)
742 pp n = pprProvenance (getNameProvenance n)
744 dupExportWarn occ_name ie1 ie2
745 = hsep [quotes (ppr occ_name),
746 ptext SLIT("is exported by"), quotes (ppr ie1),
747 ptext SLIT("and"), quotes (ppr ie2)]
750 = hsep [ptext SLIT("Duplicate"),
751 quotes (ptext SLIT("Module") <+> pprModuleName mod),
752 ptext SLIT("in export list")]
754 unusedFixityDecl rdr_name fixity
755 = hsep [ptext SLIT("Unused fixity declaration for"), quotes (ppr rdr_name)]
757 dupFixityDecl rdr_name loc1 loc2
758 = vcat [ptext SLIT("Multiple fixity declarations for") <+> quotes (ppr rdr_name),
759 ptext SLIT("at ") <+> ppr loc1,
760 ptext SLIT("and") <+> ppr loc2]