2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
4 \section[RnEnv]{Environment manipulation for the renamer monad}
7 module RnEnv where -- Export everything
9 #include "HsVersions.h"
11 import CmdLineOpts ( opt_WarnNameShadowing, opt_WarnUnusedMatches,
12 opt_WarnUnusedBinds, opt_WarnUnusedImports )
14 import RdrHsSyn ( RdrName(..), RdrNameIE,
15 rdrNameOcc, isQual, qual, isClassDataConRdrName
17 import HsTypes ( getTyVarName, replaceTyVarName )
18 import BasicTypes ( Fixity(..), FixityDirection(..), IfaceFlavour(..) )
20 import ErrUtils ( ErrMsg )
21 import Name ( Name, OccName(..), Provenance(..), ExportFlag(..), NamedThing(..),
22 occNameFlavour, getSrcLoc, occNameString,
23 NameSet, emptyNameSet, addListToNameSet, nameSetToList,
24 mkLocalName, mkGlobalName, modAndOcc,
25 nameOccName, setNameProvenance, isVarOcc, getNameProvenance,
26 pprOccName, isLocalName
28 import TyCon ( TyCon )
29 import TysWiredIn ( tupleTyCon, listTyCon, charTyCon )
31 import Unique ( Unique, Uniquable(..), unboundKey )
32 import UniqFM ( listToUFM, plusUFM_C )
34 import SrcLoc ( SrcLoc, noSrcLoc )
36 import Util ( removeDups )
38 import Char ( isAlphanum )
43 %*********************************************************
45 \subsection{Making new names}
47 %*********************************************************
50 newImportedGlobalName :: Module -> OccName
53 newImportedGlobalName mod occ hif
54 = -- First check the cache
55 getNameSupplyRn `thenRn` \ (us, inst_ns, cache) ->
58 prov = NonLocalDef noSrcLoc hif False
60 case lookupFM cache key of
62 -- A hit in the cache!
63 -- If it has no provenance at the moment then set its provenance
64 -- so that it has the right HiFlag component.
66 -- for known-key things. For example, GHCmain.lhs imports as SOURCE
67 -- Main; but Main.main is a known-key thing.)
68 -- Don't fiddle with the provenance if it already has one
69 Just name -> case getNameProvenance name of
71 new_name = setNameProvenance name prov
72 new_cache = addToFM cache key new_name
74 setNameSupplyRn (us, inst_ns, new_cache) `thenRn_`
76 other -> returnRn name
78 Nothing -> -- Miss in the cache!
79 -- Build a new original name, and put it in the cache
81 (us', us1) = splitUniqSupply us
83 name = mkGlobalName uniq mod occ prov
84 new_cache = addToFM cache key name
86 setNameSupplyRn (us', inst_ns, new_cache) `thenRn_`
91 pprC ((mod,occ),name) = pprModule mod <> text "." <> pprOccName occ <+> text "--->"
94 pprTrace "ng" (vcat [text "newGlobalName miss" <+> pprModule mod <+> pprOccName occ,
95 brackets (sep (map pprC (fmToList cache))),
101 newLocallyDefinedGlobalName :: Module -> OccName
102 -> (Name -> ExportFlag) -> SrcLoc
104 newLocallyDefinedGlobalName mod occ rec_exp_fn loc
105 = -- First check the cache
106 getNameSupplyRn `thenRn` \ (us, inst_ns, cache) ->
110 case lookupFM cache key of
112 -- A hit in the cache!
113 -- Overwrite whatever provenance is in the cache already;
114 -- this updates WiredIn things and known-key things,
115 -- which are there from the start, to LocalDef.
117 new_name = setNameProvenance name (LocalDef loc (rec_exp_fn new_name))
118 new_cache = addToFM cache key new_name
120 setNameSupplyRn (us, inst_ns, new_cache) `thenRn_`
123 -- Miss in the cache!
124 -- Build a new original name, and put it in the cache
126 provenance = LocalDef loc (rec_exp_fn new_name)
127 (us', us1) = splitUniqSupply us
129 new_name = mkGlobalName uniq mod occ provenance
130 new_cache = addToFM cache key new_name
132 setNameSupplyRn (us', inst_ns, new_cache) `thenRn_`
136 -- newDfunName is a variant, specially for dfuns.
137 -- When renaming derived definitions we are in *interface* mode (because we can trip
138 -- over original names), but we still want to make the Dfun locally-defined.
139 -- So we can't use whether or not we're in source mode to decide the locally-defined question.
140 newDfunName :: OccName -> OccName -> Maybe RdrName -> SrcLoc -> RnMS s Name
141 newDfunName _ _ (Just n) src_loc -- Imported ones have "Just n"
142 = getModuleRn `thenRn` \ mod_name ->
143 newImportedGlobalName mod_name (rdrNameOcc n) HiFile {- Correct? -}
144 newDfunName cl_nm tycon_nm Nothing src_loc -- Local instance decls have a "Nothing"
145 = getModuleRn `thenRn` \ mod_name ->
146 newInstUniq name `thenRn` \ inst_uniq ->
148 dfun_occ = VarOcc (_PK_ ("$d" ++ (_UNPK_ name) ++ show inst_uniq))
150 newLocallyDefinedGlobalName mod_name dfun_occ
151 (\_ -> Exported) src_loc
154 Dictionary names have the following form
158 where "n" is a positive number, and "tycon" is the
159 name of the type constructor for which a "class"
162 Prefixing dictionary names with their class and instance
163 types improves the behaviour of the recompilation checker.
164 (fewer recompilations required should an instance or type
165 declaration be added to a module.)
167 -- We're dropping the modids on purpose.
168 tycon_nm_str = occNameString tycon_nm
169 cl_nm_str = occNameString cl_nm
171 -- give up on any type constructor that starts with a
172 -- non-alphanumeric char (e.g., [] (,*)
174 | (_NULL_ tycon_nm_str) || not (isAlphanum (_HEAD_ (tycon_nm_str))) = cl_nm_str
175 | otherwise = cl_nm_str _APPEND_ tycon_nm_str
178 newLocalNames :: [(RdrName,SrcLoc)] -> RnM s d [Name]
179 newLocalNames rdr_names
180 = getNameSupplyRn `thenRn` \ (us, inst_ns, cache) ->
183 (us', us1) = splitUniqSupply us
184 uniqs = getUniques n us1
185 locals = [ mkLocalName uniq (rdrNameOcc rdr_name) loc
186 | ((rdr_name,loc), uniq) <- rdr_names `zip` uniqs
189 setNameSupplyRn (us', inst_ns, cache) `thenRn_`
192 -- mkUnboundName makes a place-holder Name; it shouldn't be looked at except possibly
193 -- during compiler debugging.
194 mkUnboundName :: RdrName -> Name
195 mkUnboundName rdr_name = mkLocalName unboundKey (rdrNameOcc rdr_name) noSrcLoc
197 isUnboundName :: Name -> Bool
198 isUnboundName name = uniqueOf name == unboundKey
202 bindLocatedLocalsRn :: SDoc -- Documentation string for error message
203 -> [(RdrName,SrcLoc)]
204 -> ([Name] -> RnMS s a)
206 bindLocatedLocalsRn doc_str rdr_names_w_loc enclosed_scope
207 = checkDupOrQualNames doc_str rdr_names_w_loc `thenRn_`
209 getLocalNameEnv `thenRn` \ name_env ->
210 (if opt_WarnNameShadowing
212 mapRn (check_shadow name_env) rdr_names_w_loc
217 newLocalNames rdr_names_w_loc `thenRn` \ names ->
219 new_name_env = addListToFM name_env (map fst rdr_names_w_loc `zip` names)
221 setLocalNameEnv new_name_env (enclosed_scope names)
223 check_shadow name_env (rdr_name,loc)
224 = case lookupFM name_env rdr_name of
225 Nothing -> returnRn ()
226 Just name -> pushSrcLocRn loc $
227 addWarnRn (shadowedNameWarn rdr_name)
229 bindLocalsRn doc_str rdr_names enclosed_scope
230 = getSrcLocRn `thenRn` \ loc ->
231 bindLocatedLocalsRn (text doc_str)
232 (rdr_names `zip` repeat loc)
235 bindTyVarsRn doc_str tyvar_names enclosed_scope
236 = getSrcLocRn `thenRn` \ loc ->
238 located_tyvars = [(getTyVarName tv, loc) | tv <- tyvar_names]
240 bindLocatedLocalsRn doc_str located_tyvars $ \ names ->
241 enclosed_scope (zipWith replaceTyVarName tyvar_names names)
243 -- Works in any variant of the renamer monad
244 checkDupOrQualNames, checkDupNames :: SDoc
245 -> [(RdrName, SrcLoc)]
248 checkDupOrQualNames doc_str rdr_names_w_loc
249 = -- Check for use of qualified names
250 mapRn (qualNameErr doc_str) quals `thenRn_`
251 checkDupNames doc_str rdr_names_w_loc
253 quals = filter (isQual.fst) rdr_names_w_loc
255 checkDupNames doc_str rdr_names_w_loc
256 = -- Check for dupicated names in a binding group
257 mapRn (dupNamesErr doc_str) dups `thenRn_`
260 (_, dups) = removeDups (\(n1,l1) (n2,l2) -> n1 `compare` n2) rdr_names_w_loc
264 ifaceFlavour name = case getNameProvenance name of
265 NonLocalDef _ hif _ -> hif
266 other -> HiFile -- Shouldn't happen
270 %*********************************************************
272 \subsection{Looking up names}
274 %*********************************************************
276 Looking up a name in the RnEnv.
279 checkUnboundRn :: RdrName -> Maybe Name -> RnMS s Name
280 checkUnboundRn rdr_name (Just name)
284 checkUnboundRn rdr_name Nothing
285 = -- Not found by lookup
286 getModeRn `thenRn` \ mode ->
288 -- Not found when processing source code; so fail
289 SourceMode -> failWithRn (mkUnboundName rdr_name)
290 (unknownNameErr rdr_name)
292 -- Not found when processing an imported declaration,
293 -- so we create a new name for the purpose
296 Qual mod_name occ hif -> newImportedGlobalName mod_name occ hif
298 -- An Unqual is allowed; interface files contain
299 -- unqualified names for locally-defined things, such as
300 -- constructors of a data type.
301 Unqual occ -> getModuleRn `thenRn ` \ mod_name ->
302 newImportedGlobalName mod_name occ HiFile
305 lookupBndrRn rdr_name
306 = lookupNameRn rdr_name `thenRn` \ maybe_name ->
307 checkUnboundRn rdr_name maybe_name `thenRn` \ name ->
309 if isLocalName name then
313 ----------------------------------------------------
314 -- OK, so we're at the binding site of a top-level defn
315 -- Check to see whether its an imported decl
316 getModeRn `thenRn` \ mode ->
318 SourceMode -> returnRn name ;
320 InterfaceMode _ print_unqual_fn ->
322 ----------------------------------------------------
323 -- OK, the binding site of an *imported* defn
324 -- so we can make the provenance more informative
325 getSrcLocRn `thenRn` \ src_loc ->
327 name' = case getNameProvenance name of
328 NonLocalDef _ hif _ -> setNameProvenance name
329 (NonLocalDef src_loc hif (print_unqual_fn name'))
335 -- Just like lookupRn except that we record the occurrence too
336 -- Perhaps surprisingly, even wired-in names are recorded.
337 -- Why? So that we know which wired-in names are referred to when
338 -- deciding which instance declarations to import.
339 lookupOccRn :: RdrName -> RnMS s Name
341 = lookupNameRn rdr_name `thenRn` \ maybe_name ->
342 checkUnboundRn rdr_name maybe_name `thenRn` \ name ->
344 name' = mungePrintUnqual rdr_name name
346 addOccurrenceName name'
348 -- lookupGlobalOccRn is like lookupOccRn, except that it looks in the global
349 -- environment. It's used only for
350 -- record field names
351 -- class op names in class and instance decls
352 lookupGlobalOccRn :: RdrName -> RnMS s Name
353 lookupGlobalOccRn rdr_name
354 = lookupGlobalNameRn rdr_name `thenRn` \ maybe_name ->
355 checkUnboundRn rdr_name maybe_name `thenRn` \ name ->
357 name' = mungePrintUnqual rdr_name name
359 addOccurrenceName name'
362 -- mungePrintUnqual is used to make *imported* *occurrences* print unqualified
363 -- if they were mentioned unqualified in the source code.
364 -- This improves error messages from the type checker.
365 -- NB: the binding site is treated differently; see lookupBndrRn
366 -- After the type checker all occurrences are replaced by the one
367 -- at the binding site.
368 mungePrintUnqual (Qual _ _ _) name = name
369 mungePrintUnqual (Unqual _) name = case new_prov of
371 Just prov' -> setNameProvenance name prov'
373 new_prov = case getNameProvenance name of
374 NonLocalDef loc hif False -> Just (NonLocalDef loc hif True)
377 -- lookupImplicitOccRn takes an RdrName representing an *original* name, and
378 -- adds it to the occurrence pool so that it'll be loaded later. This is
379 -- used when language constructs (such as monad comprehensions, overloaded literals,
380 -- or deriving clauses) require some stuff to be loaded that isn't explicitly
381 -- mentioned in the code.
383 -- This doesn't apply in interface mode, where everything is explicit, but
384 -- we don't check for this case: it does no harm to record an "extra" occurrence
385 -- and lookupImplicitOccRn isn't used much in interface mode (it's only the
386 -- Nothing clause of rnDerivs that calls it at all I think).
387 -- [Jan 98: this comment is wrong: rnHsType uses it quite a bit.]
389 -- For List and Tuple types it's important to get the correct
390 -- isLocallyDefined flag, which is used in turn when deciding
391 -- whether there are any instance decls in this module are "special".
392 -- The name cache should have the correct provenance, though.
394 lookupImplicitOccRn :: RdrName -> RnMS s Name
395 lookupImplicitOccRn (Qual mod occ hif)
396 = newImportedGlobalName mod occ hif `thenRn` \ name ->
397 addOccurrenceName name
399 addImplicitOccRn :: Name -> RnMS s Name
400 addImplicitOccRn name = addOccurrenceName name
402 addImplicitOccsRn :: [Name] -> RnMS s ()
403 addImplicitOccsRn names = addOccurrenceNames names
405 listType_RDR = qual (modAndOcc listType_name)
406 tupleType_RDR n = qual (modAndOcc (tupleType_name n))
408 charType_name = getName charTyCon
409 listType_name = getName listTyCon
410 tupleType_name n = getName (tupleTyCon n)
414 lookupFixity :: RdrName -> RnMS s Fixity
415 lookupFixity rdr_name
416 = getFixityEnv `thenRn` \ fixity_env ->
417 returnRn (lookupFixityEnv fixity_env rdr_name)
420 mkImportFn returns a function that takes a Name and tells whether
421 its unqualified name is in scope. This is put as a boolean flag in
422 the Name's provenance to guide whether or not to print the name qualified
426 mkImportFn :: RnEnv -> Name -> Bool
427 mkImportFn (RnEnv env _)
430 lookup name = case lookupFM env (Unqual (nameOccName name)) of
431 Just (name', _) -> name == name'
435 %************************************************************************
437 \subsection{Envt utility functions}
439 %************************************************************************
441 =============== RnEnv ================
443 plusRnEnv (RnEnv n1 f1) (RnEnv n2 f2)
444 = plusGlobalNameEnvRn n1 n2 `thenRn` \ n ->
445 plusFixityEnvRn f1 f2 `thenRn` \ f ->
450 =============== NameEnv ================
452 plusGlobalNameEnvRn :: GlobalNameEnv -> GlobalNameEnv -> RnM s d GlobalNameEnv
453 plusGlobalNameEnvRn env1 env2
454 = mapRn addNameClashErrRn (conflictsFM conflicting_name env1 env2) `thenRn_`
455 returnRn (env1 `plusFM` env2)
457 addOneToGlobalNameEnv :: GlobalNameEnv -> RdrName -> (Name, HowInScope) -> RnM s d GlobalNameEnv
458 addOneToGlobalNameEnv env rdr_name name
459 = case lookupFM env rdr_name of
460 Just name2 | conflicting_name name name2
461 -> addNameClashErrRn (rdr_name, (name, name2)) `thenRn_`
464 other -> returnRn (addToFM env rdr_name name)
466 delOneFromGlobalNameEnv :: GlobalNameEnv -> RdrName -> GlobalNameEnv
467 delOneFromGlobalNameEnv env rdr_name = delFromFM env rdr_name
469 conflicting_name :: (Name, HowInScope) -> (Name, HowInScope) -> Bool
470 conflicting_name (n1, FromLocalDefn _) (n2, FromLocalDefn _) = True
471 conflicting_name (n1,h1) (n2,h2) = n1 /= n2
472 -- We complain of a conflict if one RdrName maps to two different Names,
473 -- OR if one RdrName maps to the same *locally-defined* Name. The latter
474 -- case is to catch two separate, local definitions of the same thing.
476 -- If a module imports itself then there might be a local defn and an imported
477 -- defn of the same name; in this case the names will compare as equal, but
478 -- will still have different HowInScope fields
480 lookupNameEnv :: NameEnv -> RdrName -> Maybe Name
481 lookupNameEnv = lookupFM
484 =============== FixityEnv ================
486 plusFixityEnvRn f1 f2
487 = mapRn (addErrRn.fixityClashErr) (conflictsFM bad_fix f1 f2) `thenRn_`
488 returnRn (f1 `plusFM` f2)
490 addOneToFixityEnv env rdr_name fixity = addToFM env rdr_name fixity
492 lookupFixityEnv env rdr_name
493 = case lookupFM env rdr_name of
494 Just (fixity,_) -> fixity
495 Nothing -> Fixity 9 InfixL -- Default case
497 bad_fix :: (Fixity, HowInScope) -> (Fixity, HowInScope) -> Bool
498 bad_fix (f1,_) (f2,_) = f1 /= f2
500 pprFixityProvenance :: (Fixity, HowInScope) -> SDoc
501 pprFixityProvenance (fixity, how_in_scope) = ppr how_in_scope
506 =============== ExportAvails ================
508 mkExportAvails :: Module -> Bool -> GlobalNameEnv -> [AvailInfo] -> ExportAvails
509 mkExportAvails mod_name unqual_imp name_env avails
510 = (mod_avail_env, entity_avail_env)
512 mod_avail_env = unitFM mod_name unqual_avails
514 -- unqual_avails is the Avails that are visible in *unqualfied* form
515 -- (1.4 Report, Section 5.1.1)
517 -- import T hiding( f )
518 -- we delete f from avails
520 unqual_avails | not unqual_imp = [] -- Short cut when no unqualified imports
521 | otherwise = [prune avail | avail <- avails]
523 prune (Avail n) | unqual_in_scope n = Avail n
524 prune (Avail n) | otherwise = NotAvailable
525 prune (AvailTC n ns) = AvailTC n (filter unqual_in_scope ns)
527 unqual_in_scope n = Unqual (nameOccName n) `elemFM` name_env
529 entity_avail_env = listToUFM [ (name,avail) | avail <- avails,
530 name <- availEntityNames avail]
532 plusExportAvails :: ExportAvails -> ExportAvails -> ExportAvails
533 plusExportAvails (m1, e1) (m2, e2)
534 = (plusFM_C (++) m1 m2, plusUFM_C plusAvail e1 e2)
538 =============== AvailInfo ================
540 plusAvail (Avail n1) (Avail n2) = Avail n1
541 plusAvail (AvailTC n1 ns1) (AvailTC n2 ns2) = AvailTC n1 (nub (ns1 ++ ns2))
542 plusAvail a NotAvailable = a
543 plusAvail NotAvailable a = a
546 plusAvail a1 a2 = pprPanic "RnEnv.plusAvail" (hsep [pprAvail a1,pprAvail a2])
549 addAvailToNameSet :: NameSet -> AvailInfo -> NameSet
550 addAvailToNameSet names avail = addListToNameSet names (availNames avail)
552 availsToNameSet :: [AvailInfo] -> NameSet
553 availsToNameSet avails = foldl addAvailToNameSet emptyNameSet avails
555 availName :: AvailInfo -> Name
556 availName (Avail n) = n
557 availName (AvailTC n _) = n
559 availNames :: AvailInfo -> [Name]
560 availNames NotAvailable = []
561 availNames (Avail n) = [n]
562 availNames (AvailTC n ns) = ns
564 -- availEntityNames is used to extract the names that can appear on their own in
565 -- an export or import list. For class decls, class methods can appear on their
566 -- own, thus import A( op )
567 -- but constructors cannot; thus
569 -- means import type T from B, not constructor T.
571 availEntityNames :: AvailInfo -> [Name]
572 availEntityNames NotAvailable = []
573 availEntityNames (Avail n) = [n]
574 availEntityNames (AvailTC n ns) = n : filter (isVarOcc . nameOccName) ns
576 filterAvail :: RdrNameIE -- Wanted
577 -> AvailInfo -- Available
578 -> AvailInfo -- Resulting available;
579 -- NotAvailable if wanted stuff isn't there
581 filterAvail ie@(IEThingWith want wants) avail@(AvailTC n ns)
582 | sub_names_ok = AvailTC n (filter is_wanted ns)
585 pprTrace "filterAvail" (hsep [ppr ie, pprAvail avail]) $
589 is_wanted name = nameOccName name `elem` wanted_occs
590 sub_names_ok = all (`elem` avail_occs) wanted_occs
591 avail_occs = map nameOccName ns
592 wanted_occs = map rdrNameOcc (want:wants)
594 filterAvail (IEThingAbs _) (AvailTC n ns) = ASSERT( n `elem` ns )
597 filterAvail (IEThingAbs _) avail@(Avail n) = avail -- Type synonyms
599 filterAvail (IEVar _) avail@(Avail n) = avail
600 filterAvail (IEVar v) avail@(AvailTC n ns) = AvailTC n (filter wanted ns)
602 wanted n = nameOccName n == occ
604 -- The second equation happens if we import a class op, thus
606 -- where op is a class operation
608 filterAvail (IEThingAll _) avail@(AvailTC _ _) = avail
610 filterAvail ie avail = NotAvailable
613 -- In interfaces, pprAvail gets given the OccName of the "host" thing
614 pprAvail avail = getPprStyle $ \ sty ->
615 if ifaceStyle sty then
616 ppr_avail (pprOccName . nameOccName) avail
620 ppr_avail pp_name NotAvailable = ptext SLIT("NotAvailable")
621 ppr_avail pp_name (AvailTC n ns) = hsep [
623 parens $ hsep $ punctuate comma $
626 ppr_avail pp_name (Avail n) = pp_name n
632 %************************************************************************
634 \subsection{Finite map utilities}
636 %************************************************************************
639 Generally useful function on finite maps to check for overlap.
643 => (b->b->Bool) -- False <=> no conflict; you can pick either
644 -> FiniteMap a b -> FiniteMap a b
646 conflictsFM bad fm1 fm2
647 = filter (\(a,(b1,b2)) -> bad b1 b2)
648 (fmToList (intersectFM_C (\b1 b2 -> (b1,b2)) fm1 fm2))
652 -> FiniteMap a b -> a -> b
654 conflictFM bad fm key elt
655 = case lookupFM fm key of
656 Just elt' | bad elt elt' -> Just (key,(elt,elt'))
661 %************************************************************************
663 \subsection{Envt utility functions}
665 %************************************************************************
669 warnUnusedBinds, warnUnusedMatches, warnUnusedImports :: NameSet -> RnM s d ()
671 warnUnusedBinds names
672 | opt_WarnUnusedBinds = warnUnusedNames names
673 | otherwise = returnRn ()
675 warnUnusedMatches names
676 | opt_WarnUnusedMatches = warnUnusedNames names
677 | otherwise = returnRn ()
679 warnUnusedImports names
680 | opt_WarnUnusedImports = warnUnusedNames names
681 | otherwise = returnRn ()
683 warnUnusedNames :: NameSet -> RnM s d ()
684 warnUnusedNames names
685 = mapRn warn (nameSetToList names) `thenRn_`
688 warn name = pushSrcLocRn (getSrcLoc name) $
689 addWarnRn (unusedNameWarn name)
691 unusedNameWarn name = quotes (ppr name) <+> ptext SLIT("is bound but not used")
693 addNameClashErrRn (rdr_name, ((_,how_in_scope1), (_, how_in_scope2)))
694 | isClassDataConRdrName rdr_name
695 -- Nasty hack to prevent error messages complain about conflicts for ":C",
696 -- where "C" is a class. There'll be a message about C, and :C isn't
697 -- the programmer's business. There may be a better way to filter this
698 -- out, but I couldn't get up the energy to find it.
702 = addErrRn (hang (hsep [ptext SLIT("Conflicting definitions for"), quotes (ppr rdr_name)])
703 4 (vcat [ppr how_in_scope1,
706 fixityClashErr (rdr_name, ((_,how_in_scope1), (_, how_in_scope2)))
707 = hang (hsep [ptext SLIT("Conflicting fixities for"), quotes (ppr rdr_name)])
708 4 (vcat [ppr how_in_scope1,
711 shadowedNameWarn shadow
712 = hsep [ptext SLIT("This binding for"),
714 ptext SLIT("shadows an existing binding")]
717 = sep [text flavour, ptext SLIT("not in scope:"), quotes (ppr name)]
719 flavour = occNameFlavour (rdrNameOcc name)
721 qualNameErr descriptor (name,loc)
723 addErrRn (hsep [ ptext SLIT("Invalid use of qualified name"),
728 dupNamesErr descriptor ((name,loc) : dup_things)
730 addErrRn (hsep [ptext SLIT("Conflicting definitions for"),
732 ptext SLIT("in"), descriptor])