[project @ 2001-02-23 14:59:26 by simonpj]
[ghc-hetmet.git] / ghc / compiler / main / HscTypes.lhs
1 %
2 % (c) The University of Glasgow, 2000
3 %
4 \section[HscTypes]{Types for the per-module compiler}
5
6 \begin{code}
7 module HscTypes ( 
8         ModuleLocation(..),
9
10         ModDetails(..), ModIface(..), 
11         HomeSymbolTable, PackageTypeEnv,
12         HomeIfaceTable, PackageIfaceTable, emptyIfaceTable,
13         lookupIface, lookupIfaceByModName,
14         emptyModIface,
15
16         IfaceDecls, mkIfaceDecls, dcl_tycl, dcl_rules, dcl_insts,
17
18         VersionInfo(..), initialVersionInfo,
19
20         TyThing(..), isTyClThing, implicitTyThingIds,
21
22         TypeEnv, lookupType, mkTypeEnv, extendTypeEnvList, 
23         typeEnvClasses, typeEnvTyCons, typeEnvIds,
24
25         ImportedModuleInfo, WhetherHasOrphans, ImportVersion, WhatsImported(..),
26         PersistentRenamerState(..), IsBootInterface, Avails, DeclsMap,
27         IfaceInsts, IfaceRules, GatedDecl, IsExported,
28         NameSupply(..), OrigNameCache, OrigIParamCache,
29         AvailEnv, AvailInfo, GenAvailInfo(..),
30         PersistentCompilerState(..),
31
32         Deprecations(..), lookupDeprec,
33
34         InstEnv, ClsInstEnv, DFunId,
35         PackageInstEnv, PackageRuleBase,
36
37         GlobalRdrEnv, GlobalRdrElt(..), RdrAvailInfo, pprGlobalRdrEnv,
38
39         -- Provenance
40         Provenance(..), ImportReason(..), 
41         pprNameProvenance, hasBetterProv
42
43     ) where
44
45 #include "HsVersions.h"
46
47 import RdrName          ( RdrNameEnv, emptyRdrEnv, rdrEnvToList )
48 import Name             ( Name, NamedThing, getName, nameModule, nameSrcLoc )
49 import Name -- Env
50 import OccName          ( OccName )
51 import Module           ( Module, ModuleName, ModuleEnv,
52                           lookupModuleEnv, lookupModuleEnvByName, emptyModuleEnv
53                         )
54 import InstEnv          ( InstEnv, ClsInstEnv, DFunId )
55 import Rules            ( RuleBase )
56 import Id               ( Id )
57 import Class            ( Class, classSelIds )
58 import TyCon            ( TyCon, tyConGenIds, tyConSelIds, tyConDataConsIfAvailable )
59 import DataCon          ( dataConId, dataConWrapId )
60
61 import BasicTypes       ( Version, initialVersion, Fixity )
62
63 import HsSyn            ( DeprecTxt, tyClDeclName, ifaceRuleDeclName )
64 import RdrHsSyn         ( RdrNameInstDecl, RdrNameRuleDecl, RdrNameTyClDecl )
65 import RnHsSyn          ( RenamedTyClDecl, RenamedRuleDecl, RenamedInstDecl )
66
67 import CoreSyn          ( IdCoreRule )
68
69 import FiniteMap        ( FiniteMap )
70 import Bag              ( Bag )
71 import Maybes           ( seqMaybe )
72 import Outputable
73 import SrcLoc           ( SrcLoc, isGoodSrcLoc )
74 import Util             ( thenCmp, sortLt )
75 import UniqSupply       ( UniqSupply )
76 \end{code}
77
78 %************************************************************************
79 %*                                                                      *
80 \subsection{Module locations}
81 %*                                                                      *
82 %************************************************************************
83
84 \begin{code}
85 data ModuleLocation
86    = ModuleLocation {
87         ml_hs_file   :: Maybe FilePath,
88         ml_hspp_file :: Maybe FilePath,  -- path of preprocessed source
89         ml_hi_file   :: Maybe FilePath,
90         ml_obj_file  :: Maybe FilePath
91      }
92      deriving Show
93
94 instance Outputable ModuleLocation where
95    ppr = text . show
96 \end{code}
97
98 For a module in another package, the hs_file and obj_file
99 components of ModuleLocation are undefined.  
100
101 The locations specified by a ModuleLocation may or may not
102 correspond to actual files yet: for example, even if the object
103 file doesn't exist, the ModuleLocation still contains the path to
104 where the object file will reside if/when it is created.
105
106
107 %************************************************************************
108 %*                                                                      *
109 \subsection{Symbol tables and Module details}
110 %*                                                                      *
111 %************************************************************************
112
113 A @ModIface@ plus a @ModDetails@ summarises everything we know 
114 about a compiled module.  The @ModIface@ is the stuff *before* linking,
115 and can be written out to an interface file.  The @ModDetails@ is after
116 linking; it is the "linked" form of the mi_decls field.
117
118 \begin{code}
119 data ModIface 
120    = ModIface {
121         mi_module   :: Module,                  -- Complete with package info
122         mi_version  :: VersionInfo,             -- Module version number
123         mi_orphan   :: WhetherHasOrphans,       -- Whether this module has orphans
124         mi_boot     :: IsBootInterface,         -- Whether this interface was read from an hi-boot file
125
126         mi_usages   :: [ImportVersion Name],    -- Usages; kept sorted so that it's easy
127                                                 -- to decide whether to write a new iface file
128                                                 -- (changing usages doesn't affect the version of
129                                                 --  this module)
130
131         mi_exports  :: [(ModuleName,Avails)],   -- What it exports
132                                                 -- Kept sorted by (mod,occ),
133                                                 -- to make version comparisons easier
134
135         mi_globals  :: GlobalRdrEnv,            -- Its top level environment
136
137         mi_fixities :: NameEnv Fixity,          -- Fixities
138         mi_deprecs  :: Deprecations,            -- Deprecations
139
140         mi_decls    :: IfaceDecls               -- The RnDecls form of ModDetails
141      }
142
143 data IfaceDecls = IfaceDecls { dcl_tycl  :: [RenamedTyClDecl],  -- Sorted
144                                dcl_rules :: [RenamedRuleDecl],  -- Sorted
145                                dcl_insts :: [RenamedInstDecl] } -- Unsorted
146
147 mkIfaceDecls :: [RenamedTyClDecl] -> [RenamedRuleDecl] -> [RenamedInstDecl] -> IfaceDecls
148 mkIfaceDecls tycls rules insts
149   = IfaceDecls { dcl_tycl  = sortLt lt_tycl tycls,
150                  dcl_rules = sortLt lt_rule rules,
151                  dcl_insts = insts }
152   where
153     d1 `lt_tycl` d2 = tyClDeclName      d1 < tyClDeclName      d2
154     r1 `lt_rule` r2 = ifaceRuleDeclName r1 < ifaceRuleDeclName r2
155
156
157 -- typechecker should only look at this, not ModIface
158 -- Should be able to construct ModDetails from mi_decls in ModIface
159 data ModDetails
160    = ModDetails {
161         -- The next three fields are created by the typechecker
162         md_types    :: TypeEnv,
163         md_insts    :: [DFunId],        -- Dfun-ids for the instances in this module
164         md_rules    :: [IdCoreRule]     -- Domain may include Ids from other modules
165      }
166 \end{code}
167
168 \begin{code}
169 emptyModDetails :: ModDetails
170 emptyModDetails
171   = ModDetails { md_types = emptyTypeEnv,
172                  md_insts = [],
173                  md_rules = []
174     }
175
176 emptyModIface :: Module -> ModIface
177 emptyModIface mod
178   = ModIface { mi_module   = mod,
179                mi_version  = initialVersionInfo,
180                mi_usages   = [],
181                mi_orphan   = False,
182                mi_boot     = False,
183                mi_exports  = [],
184                mi_fixities = emptyNameEnv,
185                mi_globals  = emptyRdrEnv,
186                mi_deprecs  = NoDeprecs,
187                mi_decls    = panic "emptyModIface: decls"
188     }           
189 \end{code}
190
191 Symbol tables map modules to ModDetails:
192
193 \begin{code}
194 type SymbolTable        = ModuleEnv ModDetails
195 type IfaceTable         = ModuleEnv ModIface
196
197 type HomeIfaceTable     = IfaceTable
198 type PackageIfaceTable  = IfaceTable
199
200 type HomeSymbolTable    = SymbolTable   -- Domain = modules in the home package
201
202 emptyIfaceTable :: IfaceTable
203 emptyIfaceTable = emptyModuleEnv
204 \end{code}
205
206 Simple lookups in the symbol table.
207
208 \begin{code}
209 lookupIface :: HomeIfaceTable -> PackageIfaceTable -> Name -> Maybe ModIface
210 -- We often have two IfaceTables, and want to do a lookup
211 lookupIface hit pit name
212   = lookupModuleEnv hit mod `seqMaybe` lookupModuleEnv pit mod
213   where
214     mod = nameModule name
215
216 lookupIfaceByModName :: HomeIfaceTable -> PackageIfaceTable -> ModuleName -> Maybe ModIface
217 -- We often have two IfaceTables, and want to do a lookup
218 lookupIfaceByModName hit pit mod
219   = lookupModuleEnvByName hit mod `seqMaybe` lookupModuleEnvByName pit mod
220 \end{code}
221
222
223 %************************************************************************
224 %*                                                                      *
225 \subsection{Type environment stuff}
226 %*                                                                      *
227 %************************************************************************
228
229 \begin{code}
230 data TyThing = AnId   Id
231              | ATyCon TyCon
232              | AClass Class
233
234 isTyClThing :: TyThing -> Bool
235 isTyClThing (ATyCon _) = True
236 isTyClThing (AClass _) = True
237 isTyClThing (AnId   _) = False
238
239 instance NamedThing TyThing where
240   getName (AnId id)   = getName id
241   getName (ATyCon tc) = getName tc
242   getName (AClass cl) = getName cl
243
244 instance Outputable TyThing where
245   ppr (AnId   id) = ptext SLIT("AnId")   <+> ppr id
246   ppr (ATyCon tc) = ptext SLIT("ATyCon") <+> ppr tc
247   ppr (AClass cl) = ptext SLIT("AClass") <+> ppr cl
248
249 typeEnvClasses env = [cl | AClass cl <- nameEnvElts env]
250 typeEnvTyCons  env = [tc | ATyCon tc <- nameEnvElts env] 
251 typeEnvIds     env = [id | AnId id   <- nameEnvElts env] 
252
253 implicitTyThingIds :: [TyThing] -> [Id]
254 -- Add the implicit data cons and selectors etc 
255 implicitTyThingIds things
256   = concat (map go things)
257   where
258     go (AnId f)    = []
259     go (AClass cl) = classSelIds cl
260     go (ATyCon tc) = tyConGenIds tc ++
261                      tyConSelIds tc ++
262                      [ n | dc <- tyConDataConsIfAvailable tc, 
263                            n  <- [dataConId dc, dataConWrapId dc] ] 
264                 -- Synonyms return empty list of constructors and selectors
265 \end{code}
266
267
268 \begin{code}
269 type TypeEnv = NameEnv TyThing
270
271 emptyTypeEnv = emptyNameEnv
272
273 mkTypeEnv :: [TyThing] -> TypeEnv
274 mkTypeEnv things = extendTypeEnvList emptyTypeEnv things
275                 
276 extendTypeEnvList :: TypeEnv -> [TyThing] -> TypeEnv
277 extendTypeEnvList env things
278   = foldl add_thing env things
279   where
280     add_thing :: TypeEnv -> TyThing -> TypeEnv
281     add_thing env thing = extendNameEnv env (getName thing) thing
282 \end{code}
283
284 \begin{code}
285 lookupType :: HomeSymbolTable -> PackageTypeEnv -> Name -> Maybe TyThing
286 lookupType hst pte name
287   = case lookupModuleEnv hst (nameModule name) of
288         Just details -> lookupNameEnv (md_types details) name
289         Nothing      -> lookupNameEnv pte name
290 \end{code}
291
292 %************************************************************************
293 %*                                                                      *
294 \subsection{Auxiliary types}
295 %*                                                                      *
296 %************************************************************************
297
298 These types are defined here because they are mentioned in ModDetails,
299 but they are mostly elaborated elsewhere
300
301 \begin{code}
302 data VersionInfo 
303   = VersionInfo {
304         vers_module  :: Version,        -- Changes when anything changes
305         vers_exports :: Version,        -- Changes when export list changes
306         vers_rules   :: Version,        -- Changes when any rule changes
307         vers_decls   :: NameEnv Version
308                 -- Versions for "big" names only (not data constructors, class ops)
309                 -- The version of an Id changes if its fixity changes
310                 -- Ditto data constructors, class operations, except that the version of
311                 -- the parent class/tycon changes
312     }
313
314 initialVersionInfo :: VersionInfo
315 initialVersionInfo = VersionInfo { vers_module  = initialVersion,
316                                    vers_exports = initialVersion,
317                                    vers_rules   = initialVersion,
318                                    vers_decls   = emptyNameEnv }
319
320 data Deprecations = NoDeprecs
321                   | DeprecAll DeprecTxt                         -- Whole module deprecated
322                   | DeprecSome (NameEnv (Name,DeprecTxt))       -- Some things deprecated
323                                                                 -- Just "big" names
324                 -- We keep the Name in the range, so we can print them out
325
326 lookupDeprec :: Deprecations -> Name -> Maybe DeprecTxt
327 lookupDeprec NoDeprecs        name = Nothing
328 lookupDeprec (DeprecAll  txt) name = Just txt
329 lookupDeprec (DeprecSome env) name = case lookupNameEnv env name of
330                                             Just (_, txt) -> Just txt
331                                             Nothing       -> Nothing
332
333 instance Eq Deprecations where
334   -- Used when checking whether we need write a new interface
335   NoDeprecs       == NoDeprecs       = True
336   (DeprecAll t1)  == (DeprecAll t2)  = t1 == t2
337   (DeprecSome e1) == (DeprecSome e2) = nameEnvElts e1 == nameEnvElts e2
338   d1              == d2              = False
339 \end{code}
340
341
342 \begin{code}
343 type Avails       = [AvailInfo]
344 type AvailInfo    = GenAvailInfo Name
345 type RdrAvailInfo = GenAvailInfo OccName
346
347 data GenAvailInfo name  = Avail name     -- An ordinary identifier
348                         | AvailTC name   -- The name of the type or class
349                                   [name] -- The available pieces of type/class.
350                                          -- NB: If the type or class is itself
351                                          -- to be in scope, it must be in this list.
352                                          -- Thus, typically: AvailTC Eq [Eq, ==, /=]
353                         deriving( Eq )
354                         -- Equality used when deciding if the interface has changed
355
356 type AvailEnv     = NameEnv AvailInfo   -- Maps a Name to the AvailInfo that contains it
357                                 
358 instance Outputable n => Outputable (GenAvailInfo n) where
359    ppr = pprAvail
360
361 pprAvail :: Outputable n => GenAvailInfo n -> SDoc
362 pprAvail (AvailTC n ns) = ppr n <> case {- filter (/= n) -} ns of
363                                         []  -> empty
364                                         ns' -> braces (hsep (punctuate comma (map ppr ns')))
365
366 pprAvail (Avail n) = ppr n
367 \end{code}
368
369
370 %************************************************************************
371 %*                                                                      *
372 \subsection{ModIface}
373 %*                                                                      *
374 %************************************************************************
375
376 \begin{code}
377 type WhetherHasOrphans   = Bool
378         -- An "orphan" is 
379         --      * an instance decl in a module other than the defn module for 
380         --              one of the tycons or classes in the instance head
381         --      * a transformation rule in a module other than the one defining
382         --              the function in the head of the rule.
383
384 type IsBootInterface     = Bool
385
386 type ImportVersion name  = (ModuleName, WhetherHasOrphans, IsBootInterface, WhatsImported name)
387
388 data WhatsImported name  = NothingAtAll                         -- The module is below us in the
389                                                                 -- hierarchy, but we import nothing
390
391                          | Everything Version           -- Used for modules from other packages;
392                                                         -- we record only the module's version number
393
394                          | Specifically 
395                                 Version                 -- Module version
396                                 (Maybe Version)         -- Export-list version, if we depend on it
397                                 [(name,Version)]        -- List guaranteed non-empty
398                                 Version                 -- Rules version
399
400                          deriving( Eq )
401         -- 'Specifically' doesn't let you say "I imported f but none of the rules in
402         -- the module". If you use anything in the module you get its rule version
403         -- So if the rules change, you'll recompile, even if you don't use them.
404         -- This is easy to implement, and it's safer: you might not have used the rules last
405         -- time round, but if someone has added a new rule you might need it this time
406
407         -- The export list field is (Just v) if we depend on the export list:
408         --      we imported the module without saying exactly what we imported
409         -- We need to recompile if the module exports changes, because we might
410         -- now have a name clash in the importing module.
411
412 type IsExported = Name -> Bool          -- True for names that are exported from this module
413 \end{code}
414
415
416 %************************************************************************
417 %*                                                                      *
418 \subsection{The persistent compiler state}
419 %*                                                                      *
420 %************************************************************************
421
422 \begin{code}
423 data PersistentCompilerState 
424    = PCS {
425         pcs_PIT :: PackageIfaceTable,   -- Domain = non-home-package modules
426                                         --   the mi_decls component is empty
427
428         pcs_PTE :: PackageTypeEnv,      -- Domain = non-home-package modules
429                                         --   except that the InstEnv components is empty
430
431         pcs_insts :: PackageInstEnv,    -- The total InstEnv accumulated from all
432                                         --   the non-home-package modules
433
434         pcs_rules :: PackageRuleBase,   -- Ditto RuleEnv
435
436         pcs_PRS :: PersistentRenamerState
437      }
438 \end{code}
439
440 The @PersistentRenamerState@ persists across successive calls to the
441 compiler.
442
443 It contains:
444   * A name supply, which deals with allocating unique names to
445     (Module,OccName) original names, 
446  
447   * An accumulated TypeEnv from all the modules in imported packages
448
449   * An accumulated InstEnv from all the modules in imported packages
450     The point is that we don't want to keep recreating it whenever
451     we compile a new module.  The InstEnv component of pcPST is empty.
452     (This means we might "see" instances that we shouldn't "really" see;
453     but the Haskell Report is vague on what is meant to be visible, 
454     so we just take the easy road here.)
455
456   * Ditto for rules
457
458   * A "holding pen" for declarations that have been read out of
459     interface files but not yet sucked in, renamed, and typechecked
460
461 \begin{code}
462 type PackageTypeEnv  = TypeEnv
463 type PackageRuleBase = RuleBase
464 type PackageInstEnv  = InstEnv
465
466 data PersistentRenamerState
467   = PRS { prsOrig    :: NameSupply,
468           prsImpMods :: ImportedModuleInfo,
469           prsDecls   :: DeclsMap,
470           prsInsts   :: IfaceInsts,
471           prsRules   :: IfaceRules
472     }
473 \end{code}
474
475 The NameSupply makes sure that there is just one Unique assigned for
476 each original name; i.e. (module-name, occ-name) pair.  The Name is
477 always stored as a Global, and has the SrcLoc of its binding location.
478 Actually that's not quite right.  When we first encounter the original
479 name, we might not be at its binding site (e.g. we are reading an
480 interface file); so we give it 'noSrcLoc' then.  Later, when we find
481 its binding site, we fix it up.
482
483 Exactly the same is true of the Module stored in the Name.  When we first
484 encounter the occurrence, we may not know the details of the module, so
485 we just store junk.  Then when we find the binding site, we fix it up.
486
487 \begin{code}
488 data NameSupply
489  = NameSupply { nsUniqs :: UniqSupply,
490                 -- Supply of uniques
491                 nsNames :: OrigNameCache,
492                 -- Ensures that one original name gets one unique
493                 nsIPs   :: OrigIParamCache
494                 -- Ensures that one implicit parameter name gets one unique
495    }
496
497 type OrigNameCache   = FiniteMap (ModuleName,OccName) Name
498 type OrigIParamCache = FiniteMap OccName Name
499 \end{code}
500
501 @ImportedModuleInfo@ contains info ONLY about modules that have not yet 
502 been loaded into the iPIT.  These modules are mentioned in interfaces we've
503 already read, so we know a tiny bit about them, but we havn't yet looked
504 at the interface file for the module itself.  It needs to persist across 
505 invocations of the renamer, at least from Rename.checkOldIface to Rename.renameSource.
506 And there's no harm in it persisting across multiple compilations.
507
508 \begin{code}
509 type ImportedModuleInfo = FiniteMap ModuleName (WhetherHasOrphans, IsBootInterface)
510 \end{code}
511
512 A DeclsMap contains a binding for each Name in the declaration
513 including the constructors of a type decl etc.  The Bool is True just
514 for the 'main' Name.
515
516 \begin{code}
517 type DeclsMap = (NameEnv (AvailInfo, Bool, (Module, RdrNameTyClDecl)), Int)
518                                                 -- The Int says how many have been sucked in
519
520 type IfaceInsts = GatedDecls RdrNameInstDecl
521 type IfaceRules = GatedDecls RdrNameRuleDecl
522
523 type GatedDecls d = (Bag (GatedDecl d), Int)    -- The Int says how many have been sucked in
524 type GatedDecl  d = ([Name], (Module, d))
525 \end{code}
526
527
528 %************************************************************************
529 %*                                                                      *
530 \subsection{Provenance and export info}
531 %*                                                                      *
532 %************************************************************************
533
534 The GlobalRdrEnv gives maps RdrNames to Names.  There is a separate
535 one for each module, corresponding to that module's top-level scope.
536
537 \begin{code}
538 type GlobalRdrEnv = RdrNameEnv [GlobalRdrElt]
539         -- The list is because there may be name clashes
540         -- These only get reported on lookup, not on construction
541
542 data GlobalRdrElt = GRE Name Provenance (Maybe DeprecTxt)
543         -- The Maybe DeprecTxt tells whether this name is deprecated
544
545 pprGlobalRdrEnv env
546   = vcat (map pp (rdrEnvToList env))
547   where
548     pp (rn, nps) = ppr rn <> colon <+> 
549                    vcat [ppr n <+> pprNameProvenance n p | (GRE n p _) <- nps]
550 \end{code}
551
552 The "provenance" of something says how it came to be in scope.
553
554 \begin{code}
555 data Provenance
556   = LocalDef                    -- Defined locally
557
558   | NonLocalDef                 -- Defined non-locally
559         ImportReason
560
561 -- Just used for grouping error messages (in RnEnv.warnUnusedBinds)
562 instance Eq Provenance where
563   p1 == p2 = case p1 `compare` p2 of EQ -> True; _ -> False
564
565 instance Eq ImportReason where
566   p1 == p2 = case p1 `compare` p2 of EQ -> True; _ -> False
567
568 instance Ord Provenance where
569    compare LocalDef LocalDef = EQ
570    compare LocalDef (NonLocalDef _) = LT
571    compare (NonLocalDef _) LocalDef = GT
572
573    compare (NonLocalDef reason1) (NonLocalDef reason2) 
574       = compare reason1 reason2
575
576 instance Ord ImportReason where
577    compare ImplicitImport ImplicitImport = EQ
578    compare ImplicitImport (UserImport _ _ _) = LT
579    compare (UserImport _ _ _) ImplicitImport = GT
580    compare (UserImport m1 loc1 _) (UserImport m2 loc2 _) 
581       = (m1 `compare` m2) `thenCmp` (loc1 `compare` loc2)
582
583
584 data ImportReason
585   = UserImport Module SrcLoc Bool       -- Imported from module M on line L
586                                         -- Note the M may well not be the defining module
587                                         -- for this thing!
588         -- The Bool is true iff the thing was named *explicitly* in the import spec,
589         -- rather than being imported as part of a group; e.g.
590         --      import B
591         --      import C( T(..) )
592         -- Here, everything imported by B, and the constructors of T
593         -- are not named explicitly; only T is named explicitly.
594         -- This info is used when warning of unused names.
595
596   | ImplicitImport                      -- Imported implicitly for some other reason
597 \end{code}
598
599 \begin{code}
600 hasBetterProv :: Provenance -> Provenance -> Bool
601 -- Choose 
602 --      a local thing                 over an   imported thing
603 --      a user-imported thing         over a    non-user-imported thing
604 --      an explicitly-imported thing  over an   implicitly imported thing
605 hasBetterProv LocalDef                            _                            = True
606 hasBetterProv (NonLocalDef (UserImport _ _ _   )) (NonLocalDef ImplicitImport) = True
607 hasBetterProv _                                   _                            = False
608
609 pprNameProvenance :: Name -> Provenance -> SDoc
610 pprNameProvenance name LocalDef          = ptext SLIT("defined at") <+> ppr (nameSrcLoc name)
611 pprNameProvenance name (NonLocalDef why) = sep [ppr_reason why, 
612                                                 nest 2 (parens (ppr_defn (nameSrcLoc name)))]
613
614 ppr_reason ImplicitImport         = ptext SLIT("implicitly imported")
615 ppr_reason (UserImport mod loc _) = ptext SLIT("imported from") <+> ppr mod <+> ptext SLIT("at") <+> ppr loc
616
617 ppr_defn loc | isGoodSrcLoc loc = ptext SLIT("at") <+> ppr loc
618              | otherwise        = empty
619 \end{code}