2 % (c) The University of Glasgow 2006
3 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
8 RdrName(..), -- Constructors exported only to BinIface
11 mkRdrUnqual, mkRdrQual,
12 mkUnqual, mkVarUnqual, mkQual, mkOrig,
13 nameRdrName, getRdrName,
17 rdrNameOcc, setRdrNameSpace,
18 isRdrDataCon, isRdrTyVar, isRdrTc, isQual, isQual_maybe, isUnqual,
19 isOrig, isOrig_maybe, isExact, isExact_maybe, isSrcRdrName,
21 -- Printing; instance Outputable RdrName
24 LocalRdrEnv, emptyLocalRdrEnv, extendLocalRdrEnv,
25 lookupLocalRdrEnv, lookupLocalRdrOcc, elemLocalRdrEnv,
28 GlobalRdrEnv, emptyGlobalRdrEnv, mkGlobalRdrEnv, plusGlobalRdrEnv,
29 lookupGlobalRdrEnv, extendGlobalRdrEnv,
30 pprGlobalRdrEnv, globalRdrEnvElts,
31 lookupGRE_RdrName, lookupGRE_Name, getGRE_NameQualifier_maybes,
32 hideSomeUnquals, findLocalDupsRdrEnv,
34 -- GlobalRdrElt, Provenance, ImportSpec
35 GlobalRdrElt(..), isLocalGRE, unQualOK, qualSpecOK, unQualSpecOK,
36 Provenance(..), pprNameProvenance,
38 ImportSpec(..), ImpDeclSpec(..), ImpItemSpec(..),
39 importSpecLoc, importSpecModule, isExplicitItem
42 #include "HsVersions.h"
53 %************************************************************************
55 \subsection{The main data type}
57 %************************************************************************
62 -- Used for ordinary, unqualified occurrences
64 | Qual ModuleName OccName
65 -- A qualified name written by the user in
66 -- *source* code. The module isn't necessarily
67 -- the module where the thing is defined;
68 -- just the one from which it is imported
71 -- An original name; the module is the *defining* module.
72 -- This is used when GHC generates code that will be fed
73 -- into the renamer (e.g. from deriving clauses), but where
74 -- we want to say "Use Prelude.map dammit".
77 -- We know exactly the Name. This is used
78 -- (a) when the parser parses built-in syntax like "[]"
79 -- and "(,)", but wants a RdrName from it
80 -- (b) by Template Haskell, when TH has generated a unique name
84 %************************************************************************
86 \subsection{Simple functions}
88 %************************************************************************
91 rdrNameOcc :: RdrName -> OccName
92 rdrNameOcc (Qual _ occ) = occ
93 rdrNameOcc (Unqual occ) = occ
94 rdrNameOcc (Orig _ occ) = occ
95 rdrNameOcc (Exact name) = nameOccName name
97 setRdrNameSpace :: RdrName -> NameSpace -> RdrName
98 -- This rather gruesome function is used mainly by the parser
99 -- When parsing data T a = T | T1 Int
100 -- we parse the data constructors as *types* because of parser ambiguities,
101 -- so then we need to change the *type constr* to a *data constr*
103 -- The original-name case *can* occur when parsing
104 -- data [] a = [] | a : [a]
105 -- For the orig-name case we return an unqualified name.
106 setRdrNameSpace (Unqual occ) ns = Unqual (setOccNameSpace ns occ)
107 setRdrNameSpace (Qual m occ) ns = Qual m (setOccNameSpace ns occ)
108 setRdrNameSpace (Orig m occ) ns = Orig m (setOccNameSpace ns occ)
109 setRdrNameSpace (Exact n) ns = Orig (nameModule n)
110 (setOccNameSpace ns (nameOccName n))
114 -- These two are the basic constructors
115 mkRdrUnqual :: OccName -> RdrName
116 mkRdrUnqual occ = Unqual occ
118 mkRdrQual :: ModuleName -> OccName -> RdrName
119 mkRdrQual mod occ = Qual mod occ
121 mkOrig :: Module -> OccName -> RdrName
122 mkOrig mod occ = Orig mod occ
125 mkDerivedRdrName :: Name -> (OccName -> OccName) -> (RdrName)
126 mkDerivedRdrName parent mk_occ
127 = mkOrig (nameModule parent) (mk_occ (nameOccName parent))
130 -- These two are used when parsing source files
131 -- They do encode the module and occurrence names
132 mkUnqual :: NameSpace -> FastString -> RdrName
133 mkUnqual sp n = Unqual (mkOccNameFS sp n)
135 mkVarUnqual :: FastString -> RdrName
136 mkVarUnqual n = Unqual (mkVarOccFS n)
138 mkQual :: NameSpace -> (FastString, FastString) -> RdrName
139 mkQual sp (m, n) = Qual (mkModuleNameFS m) (mkOccNameFS sp n)
141 getRdrName :: NamedThing thing => thing -> RdrName
142 getRdrName name = nameRdrName (getName name)
144 nameRdrName :: Name -> RdrName
145 nameRdrName name = Exact name
146 -- Keep the Name even for Internal names, so that the
147 -- unique is still there for debug printing, particularly
148 -- of Types (which are converted to IfaceTypes before printing)
150 nukeExact :: Name -> RdrName
152 | isExternalName n = Orig (nameModule n) (nameOccName n)
153 | otherwise = Unqual (nameOccName n)
157 isRdrDataCon :: RdrName -> Bool
158 isRdrTyVar :: RdrName -> Bool
159 isRdrTc :: RdrName -> Bool
161 isRdrDataCon rn = isDataOcc (rdrNameOcc rn)
162 isRdrTyVar rn = isTvOcc (rdrNameOcc rn)
163 isRdrTc rn = isTcOcc (rdrNameOcc rn)
165 isSrcRdrName :: RdrName -> Bool
166 isSrcRdrName (Unqual _) = True
167 isSrcRdrName (Qual _ _) = True
168 isSrcRdrName _ = False
170 isUnqual :: RdrName -> Bool
171 isUnqual (Unqual _) = True
174 isQual :: RdrName -> Bool
175 isQual (Qual _ _) = True
178 isQual_maybe :: RdrName -> Maybe (ModuleName, OccName)
179 isQual_maybe (Qual m n) = Just (m,n)
180 isQual_maybe _ = Nothing
182 isOrig :: RdrName -> Bool
183 isOrig (Orig _ _) = True
186 isOrig_maybe :: RdrName -> Maybe (Module, OccName)
187 isOrig_maybe (Orig m n) = Just (m,n)
188 isOrig_maybe _ = Nothing
190 isExact :: RdrName -> Bool
191 isExact (Exact _) = True
194 isExact_maybe :: RdrName -> Maybe Name
195 isExact_maybe (Exact n) = Just n
196 isExact_maybe _ = Nothing
200 %************************************************************************
202 \subsection{Instances}
204 %************************************************************************
207 instance Outputable RdrName where
208 ppr (Exact name) = ppr name
209 ppr (Unqual occ) = ppr occ
210 ppr (Qual mod occ) = ppr mod <> dot <> ppr occ
211 ppr (Orig mod occ) = ppr mod <> dot <> ppr occ
213 instance OutputableBndr RdrName where
215 | isTvOcc (rdrNameOcc n) = char '@' <+> ppr n
218 instance Eq RdrName where
219 (Exact n1) == (Exact n2) = n1==n2
220 -- Convert exact to orig
221 (Exact n1) == r2@(Orig _ _) = nukeExact n1 == r2
222 r1@(Orig _ _) == (Exact n2) = r1 == nukeExact n2
224 (Orig m1 o1) == (Orig m2 o2) = m1==m2 && o1==o2
225 (Qual m1 o1) == (Qual m2 o2) = m1==m2 && o1==o2
226 (Unqual o1) == (Unqual o2) = o1==o2
229 instance Ord RdrName where
230 a <= b = case (a `compare` b) of { LT -> True; EQ -> True; GT -> False }
231 a < b = case (a `compare` b) of { LT -> True; EQ -> False; GT -> False }
232 a >= b = case (a `compare` b) of { LT -> False; EQ -> True; GT -> True }
233 a > b = case (a `compare` b) of { LT -> False; EQ -> False; GT -> True }
235 -- Exact < Unqual < Qual < Orig
236 -- [Note: Apr 2004] We used to use nukeExact to convert Exact to Orig
237 -- before comparing so that Prelude.map == the exact Prelude.map, but
238 -- that meant that we reported duplicates when renaming bindings
239 -- generated by Template Haskell; e.g
240 -- do { n1 <- newName "foo"; n2 <- newName "foo";
241 -- <decl involving n1,n2> }
242 -- I think we can do without this conversion
243 compare (Exact n1) (Exact n2) = n1 `compare` n2
244 compare (Exact _) _ = LT
246 compare (Unqual _) (Exact _) = GT
247 compare (Unqual o1) (Unqual o2) = o1 `compare` o2
248 compare (Unqual _) _ = LT
250 compare (Qual _ _) (Exact _) = GT
251 compare (Qual _ _) (Unqual _) = GT
252 compare (Qual m1 o1) (Qual m2 o2) = (o1 `compare` o2) `thenCmp` (m1 `compare` m2)
253 compare (Qual _ _) (Orig _ _) = LT
255 compare (Orig m1 o1) (Orig m2 o2) = (o1 `compare` o2) `thenCmp` (m1 `compare` m2)
256 compare (Orig _ _) _ = GT
261 %************************************************************************
265 %************************************************************************
267 A LocalRdrEnv is used for local bindings (let, where, lambda, case)
268 It is keyed by OccName, because we never use it for qualified names.
271 type LocalRdrEnv = OccEnv Name
273 emptyLocalRdrEnv :: LocalRdrEnv
274 emptyLocalRdrEnv = emptyOccEnv
276 extendLocalRdrEnv :: LocalRdrEnv -> [Name] -> LocalRdrEnv
277 extendLocalRdrEnv env names
278 = extendOccEnvList env [(nameOccName n, n) | n <- names]
280 lookupLocalRdrEnv :: LocalRdrEnv -> RdrName -> Maybe Name
281 lookupLocalRdrEnv _ (Exact name) = Just name
282 lookupLocalRdrEnv env (Unqual occ) = lookupOccEnv env occ
283 lookupLocalRdrEnv _ _ = Nothing
285 lookupLocalRdrOcc :: LocalRdrEnv -> OccName -> Maybe Name
286 lookupLocalRdrOcc env occ = lookupOccEnv env occ
288 elemLocalRdrEnv :: RdrName -> LocalRdrEnv -> Bool
289 elemLocalRdrEnv rdr_name env
290 | isUnqual rdr_name = rdrNameOcc rdr_name `elemOccEnv` env
295 %************************************************************************
299 %************************************************************************
302 type GlobalRdrEnv = OccEnv [GlobalRdrElt]
303 -- Keyed by OccName; when looking up a qualified name
304 -- we look up the OccName part, and then check the Provenance
305 -- to see if the appropriate qualification is valid. This
306 -- saves routinely doubling the size of the env by adding both
307 -- qualified and unqualified names to the domain.
309 -- The list in the range is reqd because there may be name clashes
310 -- These only get reported on lookup, not on construction
312 -- INVARIANT: All the members of the list have distinct
313 -- gre_name fields; that is, no duplicate Names
316 = GRE { gre_name :: Name,
318 gre_prov :: Provenance -- Why it's in scope
321 data Parent = NoParent | ParentIs Name
324 instance Outputable Parent where
326 ppr (ParentIs n) = ptext (sLit "parent:") <> ppr n
329 plusParent :: Parent -> Parent -> Parent
330 plusParent p1 p2 = ASSERT2( p1 == p2, parens (ppr p1) <+> parens (ppr p2) )
333 {- Why so complicated? -=chak
334 plusParent :: Parent -> Parent -> Parent
335 plusParent NoParent rel =
336 ASSERT2( case rel of { NoParent -> True; other -> False },
337 ptext (sLit "plusParent[NoParent]: ") <+> ppr rel )
339 plusParent (ParentIs n) rel =
340 ASSERT2( case rel of { ParentIs m -> n==m; other -> False },
341 ptext (sLit "plusParent[ParentIs]:") <+> ppr n <> comma <+> ppr rel )
345 emptyGlobalRdrEnv :: GlobalRdrEnv
346 emptyGlobalRdrEnv = emptyOccEnv
348 globalRdrEnvElts :: GlobalRdrEnv -> [GlobalRdrElt]
349 globalRdrEnvElts env = foldOccEnv (++) [] env
351 instance Outputable GlobalRdrElt where
352 ppr gre = ppr name <+> parens (ppr (gre_par gre) <+> pprNameProvenance gre)
356 pprGlobalRdrEnv :: GlobalRdrEnv -> SDoc
358 = vcat (map pp (occEnvElts env))
360 pp gres = ppr (nameOccName (gre_name (head gres))) <> colon <+>
361 vcat [ ppr (gre_name gre) <+> pprNameProvenance gre
366 lookupGlobalRdrEnv :: GlobalRdrEnv -> OccName -> [GlobalRdrElt]
367 lookupGlobalRdrEnv env occ_name = case lookupOccEnv env occ_name of
371 extendGlobalRdrEnv :: GlobalRdrEnv -> GlobalRdrElt -> GlobalRdrEnv
372 extendGlobalRdrEnv env gre = extendOccEnv_C add env occ [gre]
374 occ = nameOccName (gre_name gre)
375 add gres _ = gre:gres
377 lookupGRE_RdrName :: RdrName -> GlobalRdrEnv -> [GlobalRdrElt]
378 lookupGRE_RdrName rdr_name env
379 = case lookupOccEnv env (rdrNameOcc rdr_name) of
381 Just gres -> pickGREs rdr_name gres
383 lookupGRE_Name :: GlobalRdrEnv -> Name -> [GlobalRdrElt]
384 lookupGRE_Name env name
385 = [ gre | gre <- lookupGlobalRdrEnv env (nameOccName name),
386 gre_name gre == name ]
388 getGRE_NameQualifier_maybes :: GlobalRdrEnv -> Name -> [Maybe [ModuleName]]
389 getGRE_NameQualifier_maybes env
390 = map qualifier_maybe . map gre_prov . lookupGRE_Name env
391 where qualifier_maybe LocalDef = Nothing
392 qualifier_maybe (Imported iss) = Just $ map (is_as . is_decl) iss
394 pickGREs :: RdrName -> [GlobalRdrElt] -> [GlobalRdrElt]
395 -- Take a list of GREs which have the right OccName
396 -- Pick those GREs that are suitable for this RdrName
397 -- And for those, keep only only the Provenances that are suitable
400 -- module A ( f ) where
401 -- import qualified Foo( f )
404 -- Let's suppose that Foo.f and Baz.f are the same entity really.
405 -- The export of f is ambiguous because it's in scope from the local def
406 -- and the import. The lookup of (Unqual f) should return a GRE for
407 -- the locally-defined f, and a GRE for the imported f, with a *single*
408 -- provenance, namely the one for Baz(f).
409 pickGREs rdr_name gres
410 = mapCatMaybes pick gres
412 rdr_is_unqual = isUnqual rdr_name
413 rdr_is_qual = isQual_maybe rdr_name
415 pick :: GlobalRdrElt -> Maybe GlobalRdrElt
416 pick gre@(GRE {gre_prov = LocalDef, gre_name = n}) -- Local def
417 | rdr_is_unqual = Just gre
418 | Just (mod,_) <- rdr_is_qual,
419 mod == moduleName (nameModule n) = Just gre
420 | otherwise = Nothing
421 pick gre@(GRE {gre_prov = Imported [is]}) -- Single import (efficiency)
423 not (is_qual (is_decl is)) = Just gre
424 | Just (mod,_) <- rdr_is_qual,
425 mod == is_as (is_decl is) = Just gre
426 | otherwise = Nothing
427 pick gre@(GRE {gre_prov = Imported is}) -- Multiple import
428 | null filtered_is = Nothing
429 | otherwise = Just (gre {gre_prov = Imported filtered_is})
431 filtered_is | rdr_is_unqual
432 = filter (not . is_qual . is_decl) is
433 | Just (mod,_) <- rdr_is_qual
434 = filter ((== mod) . is_as . is_decl) is
438 isLocalGRE :: GlobalRdrElt -> Bool
439 isLocalGRE (GRE {gre_prov = LocalDef}) = True
442 unQualOK :: GlobalRdrElt -> Bool
443 -- An unqualifed version of this thing is in scope
444 unQualOK (GRE {gre_prov = LocalDef}) = True
445 unQualOK (GRE {gre_prov = Imported is}) = any unQualSpecOK is
447 unQualSpecOK :: ImportSpec -> Bool
448 -- In scope unqualified
449 unQualSpecOK is = not (is_qual (is_decl is))
451 qualSpecOK :: ModuleName -> ImportSpec -> Bool
452 -- In scope qualified with M
453 qualSpecOK mod is = mod == is_as (is_decl is)
455 plusGlobalRdrEnv :: GlobalRdrEnv -> GlobalRdrEnv -> GlobalRdrEnv
456 plusGlobalRdrEnv env1 env2 = plusOccEnv_C (foldr insertGRE) env1 env2
458 mkGlobalRdrEnv :: [GlobalRdrElt] -> GlobalRdrEnv
460 = foldr add emptyGlobalRdrEnv gres
462 add gre env = extendOccEnv_C (foldr insertGRE) env
463 (nameOccName (gre_name gre))
466 findLocalDupsRdrEnv :: GlobalRdrEnv -> [OccName] -> (GlobalRdrEnv, [[Name]])
467 -- For each OccName, see if there are multiple LocalDef definitions
468 -- for it. If so, remove all but one (to suppress subsequent error messages)
469 -- and return a list of the duplicate bindings
470 findLocalDupsRdrEnv rdr_env occs
473 go rdr_env dups [] = (rdr_env, dups)
474 go rdr_env dups (occ:occs)
475 = case filter isLocalGRE gres of
476 [] -> WARN( True, ppr occ <+> ppr rdr_env )
477 go rdr_env dups occs -- Weird! No binding for occ
478 [_] -> go rdr_env dups occs -- The common case
479 dup_gres -> go (extendOccEnv rdr_env occ (head dup_gres : nonlocal_gres))
480 (map gre_name dup_gres : dups)
483 gres = lookupOccEnv rdr_env occ `orElse` []
484 nonlocal_gres = filterOut isLocalGRE gres
487 insertGRE :: GlobalRdrElt -> [GlobalRdrElt] -> [GlobalRdrElt]
488 insertGRE new_g [] = [new_g]
489 insertGRE new_g (old_g : old_gs)
490 | gre_name new_g == gre_name old_g
491 = new_g `plusGRE` old_g : old_gs
493 = old_g : insertGRE new_g old_gs
495 plusGRE :: GlobalRdrElt -> GlobalRdrElt -> GlobalRdrElt
496 -- Used when the gre_name fields match
498 = GRE { gre_name = gre_name g1,
499 gre_prov = gre_prov g1 `plusProv` gre_prov g2,
500 gre_par = gre_par g1 `plusParent` gre_par g2 }
502 hideSomeUnquals :: GlobalRdrEnv -> [OccName] -> GlobalRdrEnv
503 -- Hide any unqualified bindings for the specified OccNames
504 -- This is used in TH, when renaming a declaration bracket
506 -- We want unqualified 'foo' in "..." to mean this foo, not
507 -- the one from the enclosing module. But the *qualified* name
508 -- from the enclosing moudule must certainly still be avaialable
509 -- Seems like 5 times as much work as it deserves!
510 hideSomeUnquals rdr_env occs
511 = foldr hide rdr_env occs
514 | Just gres <- lookupOccEnv env occ = extendOccEnv env occ (map qual_gre gres)
516 qual_gre gre@(GRE { gre_name = name, gre_prov = LocalDef })
517 = gre { gre_prov = Imported [imp_spec] }
518 where -- Local defs get transfomed to (fake) imported things
519 mod = moduleName (nameModule name)
520 imp_spec = ImpSpec { is_item = ImpAll, is_decl = decl_spec }
521 decl_spec = ImpDeclSpec { is_mod = mod, is_as = mod,
523 is_dloc = srcLocSpan (nameSrcLoc name) }
525 qual_gre gre@(GRE { gre_prov = Imported specs })
526 = gre { gre_prov = Imported (map qual_spec specs) }
528 qual_spec spec@(ImpSpec { is_decl = decl_spec })
529 = spec { is_decl = decl_spec { is_qual = True } }
533 %************************************************************************
537 %************************************************************************
539 The "provenance" of something says how it came to be in scope.
540 It's quite elaborate so that we can give accurate unused-name warnings.
544 = LocalDef -- Defined locally
545 | Imported -- Imported
546 [ImportSpec] -- INVARIANT: non-empty
548 data ImportSpec = ImpSpec { is_decl :: ImpDeclSpec,
549 is_item :: ImpItemSpec }
552 data ImpDeclSpec -- Describes a particular import declaration
553 -- Shared among all the Provenaces for that decl
555 is_mod :: ModuleName, -- 'import Muggle'
556 -- Note the Muggle may well not be
557 -- the defining module for this thing!
558 -- TODO: either should be Module, or there
559 -- should be a Maybe PackageId here too.
560 is_as :: ModuleName, -- 'as M' (or 'Muggle' if there is no 'as' clause)
561 is_qual :: Bool, -- True <=> qualified (only)
562 is_dloc :: SrcSpan -- Location of import declaration
565 data ImpItemSpec -- Describes import info a particular Name
566 = ImpAll -- The import had no import list,
567 -- or had a hiding list
569 | ImpSome { -- The import had an import list
571 is_iloc :: SrcSpan -- Location of the import item
573 -- The is_explicit field is True iff the thing was named
574 -- *explicitly* in the import specs rather
575 -- than being imported as part of a "..." group
576 -- e.g. import C( T(..) )
577 -- Here the constructors of T are not named explicitly;
578 -- only T is named explicitly.
580 importSpecLoc :: ImportSpec -> SrcSpan
581 importSpecLoc (ImpSpec decl ImpAll) = is_dloc decl
582 importSpecLoc (ImpSpec _ item) = is_iloc item
584 importSpecModule :: ImportSpec -> ModuleName
585 importSpecModule is = is_mod (is_decl is)
587 isExplicitItem :: ImpItemSpec -> Bool
588 isExplicitItem ImpAll = False
589 isExplicitItem (ImpSome {is_explicit = exp}) = exp
591 -- Note [Comparing provenance]
592 -- Comparison of provenance is just used for grouping
593 -- error messages (in RnEnv.warnUnusedBinds)
594 instance Eq Provenance where
595 p1 == p2 = case p1 `compare` p2 of EQ -> True; _ -> False
597 instance Eq ImpDeclSpec where
598 p1 == p2 = case p1 `compare` p2 of EQ -> True; _ -> False
600 instance Eq ImpItemSpec where
601 p1 == p2 = case p1 `compare` p2 of EQ -> True; _ -> False
603 instance Ord Provenance where
604 compare LocalDef LocalDef = EQ
605 compare LocalDef (Imported _) = LT
606 compare (Imported _ ) LocalDef = GT
607 compare (Imported is1) (Imported is2) = compare (head is1)
608 {- See Note [Comparing provenance] -} (head is2)
610 instance Ord ImpDeclSpec where
611 compare is1 is2 = (is_mod is1 `compare` is_mod is2) `thenCmp`
612 (is_dloc is1 `compare` is_dloc is2)
614 instance Ord ImpItemSpec where
615 compare is1 is2 = is_iloc is1 `compare` is_iloc is2
619 plusProv :: Provenance -> Provenance -> Provenance
620 -- Choose LocalDef over Imported
621 -- There is an obscure bug lurking here; in the presence
622 -- of recursive modules, something can be imported *and* locally
623 -- defined, and one might refer to it with a qualified name from
624 -- the import -- but I'm going to ignore that because it makes
625 -- the isLocalGRE predicate so much nicer this way
626 plusProv LocalDef LocalDef = panic "plusProv"
627 plusProv LocalDef _ = LocalDef
628 plusProv _ LocalDef = LocalDef
629 plusProv (Imported is1) (Imported is2) = Imported (is1++is2)
631 pprNameProvenance :: GlobalRdrElt -> SDoc
632 -- Print out the place where the name was imported
633 pprNameProvenance (GRE {gre_name = name, gre_prov = LocalDef})
634 = ptext (sLit "defined at") <+> ppr (nameSrcLoc name)
635 pprNameProvenance (GRE {gre_name = name, gre_prov = Imported whys})
637 (why:_) -> sep [ppr why, nest 2 (ppr_defn (nameSrcLoc name))]
638 [] -> panic "pprNameProvenance"
640 -- If we know the exact definition point (which we may do with GHCi)
641 -- then show that too. But not if it's just "imported from X".
642 ppr_defn :: SrcLoc -> SDoc
643 ppr_defn loc | isGoodSrcLoc loc = parens (ptext (sLit "defined at") <+> ppr loc)
646 instance Outputable ImportSpec where
648 = ptext (sLit "imported from") <+> ppr (importSpecModule imp_spec)
649 <+> if isGoodSrcSpan loc then ptext (sLit "at") <+> ppr loc
652 loc = importSpecLoc imp_spec