2 % (c) The University of Glasgow, 2000
4 \section[HscTypes]{Types for the per-module compiler}
12 ModDetails(..), ModIface(..),
13 HomeSymbolTable, emptySymbolTable,
15 HomeIfaceTable, PackageIfaceTable, emptyIfaceTable,
16 lookupIface, lookupIfaceByModName,
19 InteractiveContext(..),
21 IfaceDecls, mkIfaceDecls, dcl_tycl, dcl_rules, dcl_insts,
23 VersionInfo(..), initialVersionInfo, lookupVersion,
25 TyThing(..), isTyClThing, implicitTyThingIds,
27 TypeEnv, lookupType, mkTypeEnv, emptyTypeEnv,
28 extendTypeEnvList, extendTypeEnvWithIds,
29 typeEnvElts, typeEnvClasses, typeEnvTyCons, typeEnvIds,
31 ImportedModuleInfo, WhetherHasOrphans, ImportVersion, WhatsImported(..),
32 PersistentRenamerState(..), IsBootInterface, DeclsMap,
33 IfaceInsts, IfaceRules, GatedDecl, GatedDecls, GateFn, IsExported,
34 NameSupply(..), OrigNameCache, OrigIParamCache,
35 Avails, AvailEnv, emptyAvailEnv,
36 GenAvailInfo(..), AvailInfo, RdrAvailInfo,
37 PersistentCompilerState(..),
39 Deprecations(..), lookupDeprec,
41 InstEnv, ClsInstEnv, DFunId,
42 PackageInstEnv, PackageRuleBase,
44 GlobalRdrEnv, GlobalRdrElt(..), pprGlobalRdrEnv,
45 LocalRdrEnv, extendLocalRdrEnv,
49 Provenance(..), ImportReason(..),
50 pprNameProvenance, hasBetterProv
54 #include "HsVersions.h"
56 import RdrName ( RdrName, RdrNameEnv, addListToRdrEnv, emptyRdrEnv,
57 mkRdrUnqual, rdrEnvToList )
58 import Name ( Name, NamedThing, getName, nameOccName, nameModule, nameSrcLoc )
60 import OccName ( OccName )
61 import Module ( Module, ModuleName, ModuleEnv,
62 lookupModuleEnv, lookupModuleEnvByName, emptyModuleEnv
64 import InstEnv ( InstEnv, ClsInstEnv, DFunId )
65 import Rules ( RuleBase )
66 import CoreSyn ( CoreBind )
68 import Class ( Class, classSelIds )
69 import TyCon ( TyCon, isNewTyCon, tyConGenIds, tyConSelIds, tyConDataConsIfAvailable )
70 import DataCon ( dataConId, dataConWrapId )
72 import BasicTypes ( Version, initialVersion, Fixity, IPName )
74 import HsSyn ( DeprecTxt, tyClDeclName, ifaceRuleDeclName )
75 import RdrHsSyn ( RdrNameInstDecl, RdrNameRuleDecl, RdrNameTyClDecl )
76 import RnHsSyn ( RenamedTyClDecl, RenamedRuleDecl, RenamedInstDecl )
78 import CoreSyn ( IdCoreRule )
80 import FiniteMap ( FiniteMap )
82 import Maybes ( seqMaybe, orElse )
84 import SrcLoc ( SrcLoc, isGoodSrcLoc )
85 import Util ( thenCmp, sortLt )
86 import UniqSupply ( UniqSupply )
89 %************************************************************************
91 \subsection{Which mode we're in
93 %************************************************************************
96 data GhciMode = Batch | Interactive | OneShot
101 %************************************************************************
103 \subsection{Module locations}
105 %************************************************************************
110 ml_hs_file :: Maybe FilePath,
111 ml_hspp_file :: Maybe FilePath, -- path of preprocessed source
112 ml_hi_file :: FilePath,
113 ml_obj_file :: Maybe FilePath
117 instance Outputable ModuleLocation where
121 For a module in another package, the hs_file and obj_file
122 components of ModuleLocation are undefined.
124 The locations specified by a ModuleLocation may or may not
125 correspond to actual files yet: for example, even if the object
126 file doesn't exist, the ModuleLocation still contains the path to
127 where the object file will reside if/when it is created.
130 %************************************************************************
132 \subsection{Symbol tables and Module details}
134 %************************************************************************
136 A @ModIface@ plus a @ModDetails@ summarises everything we know
137 about a compiled module. The @ModIface@ is the stuff *before* linking,
138 and can be written out to an interface file. (The @ModDetails@ is after
139 linking; it is the "linked" form of the mi_decls field.)
141 When we *read* an interface file, we also construct a @ModIface@ from it,
142 except that the mi_decls part is empty; when reading we consolidate
143 the declarations into a single indexed map in the @PersistentRenamerState@.
148 mi_module :: !Module, -- Complete with package info
149 mi_version :: !VersionInfo, -- Module version number
151 mi_orphan :: WhetherHasOrphans, -- Whether this module has orphans
152 -- NOT STRICT! we fill this field with _|_ sometimes
154 mi_boot :: !IsBootInterface, -- read from an hi-boot file?
156 mi_usages :: ![ImportVersion Name],
157 -- Usages; kept sorted so that it's easy to decide
158 -- whether to write a new iface file (changing usages
159 -- doesn't affect the version of this module)
161 mi_exports :: ![(ModuleName,Avails)],
162 -- What it exports Kept sorted by (mod,occ), to make
163 -- version comparisons easier
165 mi_globals :: !(Maybe GlobalRdrEnv),
166 -- Its top level environment or Nothing if we read this
167 -- interface from a file.
169 mi_fixities :: !(NameEnv Fixity), -- Fixities
170 mi_deprecs :: !Deprecations, -- Deprecations
172 mi_decls :: IfaceDecls -- The RnDecls form of ModDetails
173 -- NOT STRICT! we fill this field with _|_ sometimes
176 data IfaceDecls = IfaceDecls { dcl_tycl :: [RenamedTyClDecl], -- Sorted
177 dcl_rules :: [RenamedRuleDecl], -- Sorted
178 dcl_insts :: [RenamedInstDecl] } -- Unsorted
180 mkIfaceDecls :: [RenamedTyClDecl] -> [RenamedRuleDecl] -> [RenamedInstDecl] -> IfaceDecls
181 mkIfaceDecls tycls rules insts
182 = IfaceDecls { dcl_tycl = sortLt lt_tycl tycls,
183 dcl_rules = sortLt lt_rule rules,
186 d1 `lt_tycl` d2 = tyClDeclName d1 < tyClDeclName d2
187 r1 `lt_rule` r2 = ifaceRuleDeclName r1 < ifaceRuleDeclName r2
190 -- typechecker should only look at this, not ModIface
191 -- Should be able to construct ModDetails from mi_decls in ModIface
194 -- The next three fields are created by the typechecker
195 md_types :: !TypeEnv,
196 md_insts :: ![DFunId], -- Dfun-ids for the instances in this module
197 md_rules :: ![IdCoreRule], -- Domain may include Ids from other modules
198 md_binds :: ![CoreBind]
201 -- The ModDetails takes on several slightly different forms:
203 -- After typecheck + desugar
204 -- md_types Contains TyCons, Classes, and implicit Ids
205 -- md_insts All instances from this module (incl derived ones)
206 -- md_rules All rules from this module
207 -- md_binds Desugared bindings
209 -- After simplification
210 -- md_types Same as after typecheck
212 -- md_rules Orphan rules only (local ones now attached to binds)
213 -- md_binds With rules attached
216 -- md_types Now contains Ids as well, replete with final IdInfo
217 -- The Ids are only the ones that are visible from
218 -- importing modules. Without -O that means only
219 -- exported Ids, but with -O importing modules may
220 -- see ids mentioned in unfoldings of exported Ids
222 -- md_insts Same DFunIds as before, but with final IdInfo,
223 -- and the unique might have changed; remember that
224 -- CoreTidy links up the uniques of old and new versions
226 -- md_rules All rules for exported things, substituted with final Ids
230 -- Passed back to compilation manager
231 -- Just as after CoreTidy, but with md_binds nuked
236 emptyModIface :: Module -> ModIface
238 = ModIface { mi_module = mod,
239 mi_version = initialVersionInfo,
244 mi_fixities = emptyNameEnv,
245 mi_globals = Nothing,
246 mi_deprecs = NoDeprecs,
247 mi_decls = panic "emptyModIface: decls"
251 Symbol tables map modules to ModDetails:
254 type SymbolTable = ModuleEnv ModDetails
255 type IfaceTable = ModuleEnv ModIface
257 type HomeIfaceTable = IfaceTable
258 type PackageIfaceTable = IfaceTable
260 type HomeSymbolTable = SymbolTable -- Domain = modules in the home package
262 emptySymbolTable :: SymbolTable
263 emptySymbolTable = emptyModuleEnv
265 emptyIfaceTable :: IfaceTable
266 emptyIfaceTable = emptyModuleEnv
269 Simple lookups in the symbol table.
272 lookupIface :: HomeIfaceTable -> PackageIfaceTable -> Name -> Maybe ModIface
273 -- We often have two IfaceTables, and want to do a lookup
274 lookupIface hit pit name
275 = lookupModuleEnv hit mod `seqMaybe` lookupModuleEnv pit mod
277 mod = nameModule name
279 lookupIfaceByModName :: HomeIfaceTable -> PackageIfaceTable -> ModuleName -> Maybe ModIface
280 -- We often have two IfaceTables, and want to do a lookup
281 lookupIfaceByModName hit pit mod
282 = lookupModuleEnvByName hit mod `seqMaybe` lookupModuleEnvByName pit mod
286 %************************************************************************
288 \subsection{The interactive context}
290 %************************************************************************
293 data InteractiveContext
294 = InteractiveContext {
295 ic_module :: Module, -- The current module in which
296 -- the user is sitting
298 ic_rn_env :: LocalRdrEnv, -- Lexical context for variables bound
299 -- during interaction
301 ic_type_env :: TypeEnv -- Ditto for types
306 %************************************************************************
308 \subsection{Type environment stuff}
310 %************************************************************************
313 data TyThing = AnId Id
317 isTyClThing :: TyThing -> Bool
318 isTyClThing (ATyCon _) = True
319 isTyClThing (AClass _) = True
320 isTyClThing (AnId _) = False
322 instance NamedThing TyThing where
323 getName (AnId id) = getName id
324 getName (ATyCon tc) = getName tc
325 getName (AClass cl) = getName cl
327 instance Outputable TyThing where
328 ppr (AnId id) = ptext SLIT("AnId") <+> ppr id
329 ppr (ATyCon tc) = ptext SLIT("ATyCon") <+> ppr tc
330 ppr (AClass cl) = ptext SLIT("AClass") <+> ppr cl
333 typeEnvElts :: TypeEnv -> [TyThing]
334 typeEnvClasses :: TypeEnv -> [Class]
335 typeEnvTyCons :: TypeEnv -> [TyCon]
336 typeEnvIds :: TypeEnv -> [Id]
338 typeEnvElts env = nameEnvElts env
339 typeEnvClasses env = [cl | AClass cl <- typeEnvElts env]
340 typeEnvTyCons env = [tc | ATyCon tc <- typeEnvElts env]
341 typeEnvIds env = [id | AnId id <- typeEnvElts env]
343 implicitTyThingIds :: [TyThing] -> [Id]
344 -- Add the implicit data cons and selectors etc
345 implicitTyThingIds things
346 = concat (map go things)
349 go (AClass cl) = classSelIds cl
350 go (ATyCon tc) = tyConGenIds tc ++
352 [ n | dc <- tyConDataConsIfAvailable tc,
353 n <- implicitConIds tc dc]
354 -- Synonyms return empty list of constructors and selectors
356 implicitConIds tc dc -- Newtypes have a constructor wrapper,
358 | isNewTyCon tc = [dataConWrapId dc]
359 | otherwise = [dataConId dc, dataConWrapId dc]
364 type TypeEnv = NameEnv TyThing
366 emptyTypeEnv = emptyNameEnv
368 mkTypeEnv :: [TyThing] -> TypeEnv
369 mkTypeEnv things = extendTypeEnvList emptyTypeEnv things
371 extendTypeEnvList :: TypeEnv -> [TyThing] -> TypeEnv
372 extendTypeEnvList env things
373 = extendNameEnvList env [(getName thing, thing) | thing <- things]
375 extendTypeEnvWithIds :: TypeEnv -> [Id] -> TypeEnv
376 extendTypeEnvWithIds env ids
377 = extendNameEnvList env [(getName id, AnId id) | id <- ids]
381 lookupType :: HomeSymbolTable -> PackageTypeEnv -> Name -> Maybe TyThing
382 lookupType hst pte name
383 = case lookupModuleEnv hst (nameModule name) of
384 Just details -> lookupNameEnv (md_types details) name
385 Nothing -> lookupNameEnv pte name
388 %************************************************************************
390 \subsection{Auxiliary types}
392 %************************************************************************
394 These types are defined here because they are mentioned in ModDetails,
395 but they are mostly elaborated elsewhere
400 vers_module :: Version, -- Changes when anything changes
401 vers_exports :: Version, -- Changes when export list changes
402 vers_rules :: Version, -- Changes when any rule changes
403 vers_decls :: NameEnv Version
404 -- Versions for "big" names only (not data constructors, class ops)
405 -- The version of an Id changes if its fixity changes
406 -- Ditto data constructors, class operations, except that the version of
407 -- the parent class/tycon changes
409 -- If a name isn't in the map, it means 'initialVersion'
412 initialVersionInfo :: VersionInfo
413 initialVersionInfo = VersionInfo { vers_module = initialVersion,
414 vers_exports = initialVersion,
415 vers_rules = initialVersion,
416 vers_decls = emptyNameEnv
419 lookupVersion :: NameEnv Version -> Name -> Version
420 lookupVersion env name = lookupNameEnv env name `orElse` initialVersion
422 data Deprecations = NoDeprecs
423 | DeprecAll DeprecTxt -- Whole module deprecated
424 | DeprecSome (NameEnv (Name,DeprecTxt)) -- Some things deprecated
426 -- We keep the Name in the range, so we can print them out
428 lookupDeprec :: Deprecations -> Name -> Maybe DeprecTxt
429 lookupDeprec NoDeprecs name = Nothing
430 lookupDeprec (DeprecAll txt) name = Just txt
431 lookupDeprec (DeprecSome env) name = case lookupNameEnv env name of
432 Just (_, txt) -> Just txt
435 instance Eq Deprecations where
436 -- Used when checking whether we need write a new interface
437 NoDeprecs == NoDeprecs = True
438 (DeprecAll t1) == (DeprecAll t2) = t1 == t2
439 (DeprecSome e1) == (DeprecSome e2) = nameEnvElts e1 == nameEnvElts e2
445 type Avails = [AvailInfo]
446 type AvailInfo = GenAvailInfo Name
447 type RdrAvailInfo = GenAvailInfo OccName
449 data GenAvailInfo name = Avail name -- An ordinary identifier
450 | AvailTC name -- The name of the type or class
451 [name] -- The available pieces of type/class.
452 -- NB: If the type or class is itself
453 -- to be in scope, it must be in this list.
454 -- Thus, typically: AvailTC Eq [Eq, ==, /=]
456 -- Equality used when deciding if the interface has changed
458 type AvailEnv = NameEnv AvailInfo -- Maps a Name to the AvailInfo that contains it
460 emptyAvailEnv :: AvailEnv
461 emptyAvailEnv = emptyNameEnv
463 instance Outputable n => Outputable (GenAvailInfo n) where
466 pprAvail :: Outputable n => GenAvailInfo n -> SDoc
467 pprAvail (AvailTC n ns) = ppr n <> case {- filter (/= n) -} ns of
469 ns' -> braces (hsep (punctuate comma (map ppr ns')))
471 pprAvail (Avail n) = ppr n
475 %************************************************************************
477 \subsection{ModIface}
479 %************************************************************************
482 type WhetherHasOrphans = Bool
484 -- * an instance decl in a module other than the defn module for
485 -- one of the tycons or classes in the instance head
486 -- * a transformation rule in a module other than the one defining
487 -- the function in the head of the rule.
489 type IsBootInterface = Bool
491 type ImportVersion name = (ModuleName, WhetherHasOrphans, IsBootInterface, WhatsImported name)
493 data WhatsImported name = NothingAtAll -- The module is below us in the
494 -- hierarchy, but we import nothing
496 | Everything Version -- Used for modules from other packages;
497 -- we record only the module's version number
500 Version -- Module version
501 (Maybe Version) -- Export-list version, if we depend on it
502 [(name,Version)] -- List guaranteed non-empty
503 Version -- Rules version
506 -- 'Specifically' doesn't let you say "I imported f but none of the rules in
507 -- the module". If you use anything in the module you get its rule version
508 -- So if the rules change, you'll recompile, even if you don't use them.
509 -- This is easy to implement, and it's safer: you might not have used the rules last
510 -- time round, but if someone has added a new rule you might need it this time
512 -- The export list field is (Just v) if we depend on the export list:
513 -- we imported the module without saying exactly what we imported
514 -- We need to recompile if the module exports changes, because we might
515 -- now have a name clash in the importing module.
517 type IsExported = Name -> Bool -- True for names that are exported from this module
521 %************************************************************************
523 \subsection{The persistent compiler state}
525 %************************************************************************
527 The @PersistentCompilerState@ persists across successive calls to the
530 * A ModIface for each non-home-package module
532 * An accumulated TypeEnv from all the modules in imported packages
534 * An accumulated InstEnv from all the modules in imported packages
535 The point is that we don't want to keep recreating it whenever
536 we compile a new module. The InstEnv component of pcPST is empty.
537 (This means we might "see" instances that we shouldn't "really" see;
538 but the Haskell Report is vague on what is meant to be visible,
539 so we just take the easy road here.)
543 * The persistent renamer state
546 data PersistentCompilerState
548 pcs_PIT :: !PackageIfaceTable, -- Domain = non-home-package modules
549 -- the mi_decls component is empty
551 pcs_PTE :: !PackageTypeEnv, -- Domain = non-home-package modules
552 -- except that the InstEnv components is empty
554 pcs_insts :: !PackageInstEnv, -- The total InstEnv accumulated from all
555 -- the non-home-package modules
557 pcs_rules :: !PackageRuleBase, -- Ditto RuleEnv
559 pcs_PRS :: !PersistentRenamerState
564 The persistent renamer state contains:
566 * A name supply, which deals with allocating unique names to
567 (Module,OccName) original names,
569 * A "holding pen" for declarations that have been read out of
570 interface files but not yet sucked in, renamed, and typechecked
573 type PackageTypeEnv = TypeEnv
574 type PackageRuleBase = RuleBase
575 type PackageInstEnv = InstEnv
577 data PersistentRenamerState
578 = PRS { prsOrig :: !NameSupply,
579 prsImpMods :: !ImportedModuleInfo,
581 -- Holding pens for stuff that has been read in
582 -- but not yet slurped into the renamer
583 prsDecls :: !DeclsMap,
584 prsInsts :: !IfaceInsts,
585 prsRules :: !IfaceRules
589 The NameSupply makes sure that there is just one Unique assigned for
590 each original name; i.e. (module-name, occ-name) pair. The Name is
591 always stored as a Global, and has the SrcLoc of its binding location.
592 Actually that's not quite right. When we first encounter the original
593 name, we might not be at its binding site (e.g. we are reading an
594 interface file); so we give it 'noSrcLoc' then. Later, when we find
595 its binding site, we fix it up.
597 Exactly the same is true of the Module stored in the Name. When we first
598 encounter the occurrence, we may not know the details of the module, so
599 we just store junk. Then when we find the binding site, we fix it up.
603 = NameSupply { nsUniqs :: UniqSupply,
605 nsNames :: OrigNameCache,
606 -- Ensures that one original name gets one unique
607 nsIPs :: OrigIParamCache
608 -- Ensures that one implicit parameter name gets one unique
611 type OrigNameCache = FiniteMap (ModuleName,OccName) Name
612 type OrigIParamCache = FiniteMap (IPName RdrName) (IPName Name)
615 @ImportedModuleInfo@ contains info ONLY about modules that have not yet
616 been loaded into the iPIT. These modules are mentioned in interfaces we've
617 already read, so we know a tiny bit about them, but we havn't yet looked
618 at the interface file for the module itself. It needs to persist across
619 invocations of the renamer, at least from Rename.checkOldIface to Rename.renameSource.
620 And there's no harm in it persisting across multiple compilations.
623 type ImportedModuleInfo = FiniteMap ModuleName (WhetherHasOrphans, IsBootInterface)
626 A DeclsMap contains a binding for each Name in the declaration
627 including the constructors of a type decl etc. The Bool is True just
631 type DeclsMap = (NameEnv (AvailInfo, Bool, (Module, RdrNameTyClDecl)), Int)
632 -- The Int says how many have been sucked in
634 type IfaceInsts = GatedDecls RdrNameInstDecl
635 type IfaceRules = GatedDecls RdrNameRuleDecl
637 type GatedDecls d = (Bag (GatedDecl d), Int) -- The Int says how many have been sucked in
638 type GatedDecl d = (GateFn, (Module, d))
639 type GateFn = (Name -> Bool) -> Bool -- Returns True <=> gate is open
640 -- The (Name -> Bool) fn returns True for visible Names
641 -- For example, suppose this is in an interface file
642 -- instance C T where ...
643 -- We want to slurp this decl if both C and T are "visible" in
644 -- the importing module. See "The gating story" in RnIfaces for details.
648 %************************************************************************
650 \subsection{Provenance and export info}
652 %************************************************************************
654 A LocalRdrEnv is used for local bindings (let, where, lambda, case)
657 type LocalRdrEnv = RdrNameEnv Name
659 extendLocalRdrEnv :: LocalRdrEnv -> [Name] -> LocalRdrEnv
660 extendLocalRdrEnv env names
661 = addListToRdrEnv env [(mkRdrUnqual (nameOccName n), n) | n <- names]
664 The GlobalRdrEnv gives maps RdrNames to Names. There is a separate
665 one for each module, corresponding to that module's top-level scope.
668 type GlobalRdrEnv = RdrNameEnv [GlobalRdrElt]
669 -- The list is because there may be name clashes
670 -- These only get reported on lookup, not on construction
672 data GlobalRdrElt = GRE Name Provenance (Maybe DeprecTxt)
673 -- The Maybe DeprecTxt tells whether this name is deprecated
676 = vcat (map pp (rdrEnvToList env))
678 pp (rn, nps) = ppr rn <> colon <+>
679 vcat [ppr n <+> pprNameProvenance n p | (GRE n p _) <- nps]
682 The "provenance" of something says how it came to be in scope.
686 = LocalDef -- Defined locally
688 | NonLocalDef -- Defined non-locally
691 -- Just used for grouping error messages (in RnEnv.warnUnusedBinds)
692 instance Eq Provenance where
693 p1 == p2 = case p1 `compare` p2 of EQ -> True; _ -> False
695 instance Eq ImportReason where
696 p1 == p2 = case p1 `compare` p2 of EQ -> True; _ -> False
698 instance Ord Provenance where
699 compare LocalDef LocalDef = EQ
700 compare LocalDef (NonLocalDef _) = LT
701 compare (NonLocalDef _) LocalDef = GT
703 compare (NonLocalDef reason1) (NonLocalDef reason2)
704 = compare reason1 reason2
706 instance Ord ImportReason where
707 compare ImplicitImport ImplicitImport = EQ
708 compare ImplicitImport (UserImport _ _ _) = LT
709 compare (UserImport _ _ _) ImplicitImport = GT
710 compare (UserImport m1 loc1 _) (UserImport m2 loc2 _)
711 = (m1 `compare` m2) `thenCmp` (loc1 `compare` loc2)
715 = UserImport Module SrcLoc Bool -- Imported from module M on line L
716 -- Note the M may well not be the defining module
718 -- The Bool is true iff the thing was named *explicitly* in the import spec,
719 -- rather than being imported as part of a group; e.g.
722 -- Here, everything imported by B, and the constructors of T
723 -- are not named explicitly; only T is named explicitly.
724 -- This info is used when warning of unused names.
726 | ImplicitImport -- Imported implicitly for some other reason
730 hasBetterProv :: Provenance -> Provenance -> Bool
732 -- a local thing over an imported thing
733 -- a user-imported thing over a non-user-imported thing
734 -- an explicitly-imported thing over an implicitly imported thing
735 hasBetterProv LocalDef _ = True
736 hasBetterProv (NonLocalDef (UserImport _ _ _ )) (NonLocalDef ImplicitImport) = True
737 hasBetterProv _ _ = False
739 pprNameProvenance :: Name -> Provenance -> SDoc
740 pprNameProvenance name LocalDef = ptext SLIT("defined at") <+> ppr (nameSrcLoc name)
741 pprNameProvenance name (NonLocalDef why) = sep [ppr_reason why,
742 nest 2 (ppr_defn (nameSrcLoc name))]
744 ppr_reason ImplicitImport = ptext SLIT("implicitly imported")
745 ppr_reason (UserImport mod loc _) = ptext SLIT("imported from") <+> ppr mod <+> ptext SLIT("at") <+> ppr loc
747 ppr_defn loc | isGoodSrcLoc loc = parens (ptext SLIT("at") <+> ppr loc)