2 % (c) The University of Glasgow 2006
3 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
6 Loading interface files
10 loadInterface, loadInterfaceForName, loadWiredInHomeIface,
11 loadSrcInterface, loadSysInterface, loadOrphanModules,
12 findAndReadIface, readIface, -- Used when reading the module's old interface
13 loadDecls, -- Should move to TcIface and be renamed
14 initExternalPackageState,
16 ifaceStats, pprModIface, showIface
19 #include "HsVersions.h"
21 import {-# SOURCE #-} TcIface( tcIfaceDecl, tcIfaceRules, tcIfaceInst,
22 tcIfaceFamInst, tcIfaceVectInfo )
29 import BasicTypes hiding (SuccessFlag(..))
62 %************************************************************************
64 loadSrcInterface, loadOrphanModules, loadHomeInterface
66 These three are called from TcM-land
68 %************************************************************************
71 -- | Load the interface corresponding to an @import@ directive in
72 -- source code. On a failure, fail in the monad with an error message.
73 loadSrcInterface :: SDoc
75 -> IsBootInterface -- {-# SOURCE #-} ?
76 -> Maybe FastString -- "package", if any
79 loadSrcInterface doc mod want_boot maybe_pkg = do
80 -- We must first find which Module this import refers to. This involves
81 -- calling the Finder, which as a side effect will search the filesystem
82 -- and create a ModLocation. If successful, loadIface will read the
83 -- interface; it will call the Finder again, but the ModLocation will be
84 -- cached from the first search.
86 res <- liftIO $ findImportedModule hsc_env mod maybe_pkg
89 mb_iface <- initIfaceTcRn $ loadInterface doc mod (ImportByUser want_boot)
91 Failed err -> failWithTc err
92 Succeeded iface -> return iface
94 let dflags = hsc_dflags hsc_env in
95 failWithTc (cannotFindInterface dflags mod err)
97 -- | Load interfaces for a collection of orphan modules.
98 loadOrphanModules :: [Module] -- the modules
99 -> Bool -- these are family instance-modules
101 loadOrphanModules mods isFamInstMod
102 | null mods = return ()
103 | otherwise = initIfaceTcRn $
104 do { traceIf (text "Loading orphan modules:" <+>
109 load mod = loadSysInterface (mk_doc mod) mod
111 | isFamInstMod = ppr mod <+> ptext (sLit "is a family-instance module")
112 | otherwise = ppr mod <+> ptext (sLit "is a orphan-instance module")
114 -- | Loads the interface for a given Name.
115 loadInterfaceForName :: SDoc -> Name -> TcRn ModIface
116 loadInterfaceForName doc name
119 -- Should not be called with a name from the module being compiled
120 { this_mod <- getModule
121 ; MASSERT2( not (nameIsLocalOrFrom this_mod name), ppr name <+> parens doc )
123 ; initIfaceTcRn $ loadSysInterface doc (nameModule name)
126 -- | An 'IfM' function to load the home interface for a wired-in thing,
127 -- so that we're sure that we see its instance declarations and rules
128 -- See Note [Loading instances]
129 loadWiredInHomeIface :: Name -> IfM lcl ()
130 loadWiredInHomeIface name
131 = ASSERT( isWiredInName name )
132 do loadSysInterface doc (nameModule name); return ()
134 doc = ptext (sLit "Need home interface for wired-in thing") <+> ppr name
136 -- | A wrapper for 'loadInterface' that throws an exception if it fails
137 loadSysInterface :: SDoc -> Module -> IfM lcl ModIface
138 loadSysInterface doc mod_name
139 = do { mb_iface <- loadInterface doc mod_name ImportBySystem
141 Failed err -> ghcError (ProgramError (showSDoc err))
142 Succeeded iface -> return iface }
145 Note [Loading instances]
146 ~~~~~~~~~~~~~~~~~~~~~~~~
147 We need to make sure that we have at least *read* the interface files
148 for any module with an instance decl or RULE that we might want.
150 * If the instance decl is an orphan, we have a whole separate mechanism
153 * If the instance decl not an orphan, then the act of looking at the
154 TyCon or Class will force in the defining module for the
155 TyCon/Class, and hence the instance decl
157 * BUT, if the TyCon is a wired-in TyCon, we don't really need its interface;
158 but we must make sure we read its interface in case it has instances or
159 rules. That is what LoadIface.loadWiredInHomeInterface does. It's called
160 from TcIface.{tcImportDecl, checkWiredInTyCon, ifCHeckWiredInThing}
162 All of this is done by the type checker. The renamer plays no role.
163 (It used to, but no longer.)
167 %*********************************************************
171 The main function to load an interface
172 for an imported module, and put it in
173 the External Package State
175 %*********************************************************
178 loadInterface :: SDoc -> Module -> WhereFrom
179 -> IfM lcl (MaybeErr Message ModIface)
181 -- loadInterface looks in both the HPT and PIT for the required interface
182 -- If not found, it loads it, and puts it in the PIT (always).
184 -- If it can't find a suitable interface file, we
185 -- a) modify the PackageIfaceTable to have an empty entry
186 -- (to avoid repeated complaints)
187 -- b) return (Left message)
189 -- It's not necessarily an error for there not to be an interface
190 -- file -- perhaps the module has changed, and that interface
193 loadInterface doc_str mod from
194 = do { -- Read the state
195 (eps,hpt) <- getEpsAndHpt
197 ; traceIf (text "Considering whether to load" <+> ppr mod <+> ppr from)
199 -- Check whether we have the interface already
201 ; case lookupIfaceByModule dflags hpt (eps_PIT eps) mod of {
203 -> return (Succeeded iface) ; -- Already loaded
204 -- The (src_imp == mi_boot iface) test checks that the already-loaded
205 -- interface isn't a boot iface. This can conceivably happen,
206 -- if an earlier import had a before we got to real imports. I think.
209 let { hi_boot_file = case from of
210 ImportByUser usr_boot -> usr_boot
211 ImportBySystem -> sys_boot
213 ; mb_dep = lookupUFM (eps_is_boot eps) (moduleName mod)
214 ; sys_boot = case mb_dep of
215 Just (_, is_boot) -> is_boot
217 -- The boot-ness of the requested interface,
218 } -- based on the dependencies in directly-imported modules
220 -- READ THE MODULE IN
221 ; read_result <- findAndReadIface doc_str mod hi_boot_file
222 ; case read_result of {
224 { let fake_iface = emptyModIface mod
226 ; updateEps_ $ \eps ->
227 eps { eps_PIT = extendModuleEnv (eps_PIT eps) (mi_module fake_iface) fake_iface }
228 -- Not found, so add an empty iface to
229 -- the EPS map so that we don't look again
231 ; return (Failed err) } ;
234 Succeeded (iface, file_path) -- Sanity check:
235 | ImportBySystem <- from, -- system-importing...
236 modulePackageId (mi_module iface) == thisPackage dflags,
237 -- a home-package module...
238 Nothing <- mb_dep -- that we know nothing about
239 -> return (Failed (badDepMsg mod))
244 loc_doc = text file_path
246 initIfaceLcl mod loc_doc $ do
248 -- Load the new ModIface into the External Package State
249 -- Even home-package interfaces loaded by loadInterface
250 -- (which only happens in OneShot mode; in Batch/Interactive
251 -- mode, home-package modules are loaded one by one into the HPT)
252 -- are put in the EPS.
254 -- The main thing is to add the ModIface to the PIT, but
256 -- IfaceDecls, IfaceInst, IfaceFamInst, IfaceRules, IfaceVectInfo
257 -- out of the ModIface and put them into the big EPS pools
259 -- NB: *first* we do loadDecl, so that the provenance of all the locally-defined
260 --- names is done correctly (notably, whether this is an .hi file or .hi-boot file).
261 -- If we do loadExport first the wrong info gets into the cache (unless we
262 -- explicitly tag each export which seems a bit of a bore)
264 ; ignore_prags <- doptM Opt_IgnoreInterfacePragmas
265 ; new_eps_decls <- loadDecls ignore_prags (mi_decls iface)
266 ; new_eps_insts <- mapM tcIfaceInst (mi_insts iface)
267 ; new_eps_fam_insts <- mapM tcIfaceFamInst (mi_fam_insts iface)
268 ; new_eps_rules <- tcIfaceRules ignore_prags (mi_rules iface)
269 ; new_eps_vect_info <- tcIfaceVectInfo mod (mkNameEnv new_eps_decls)
272 ; let { final_iface = iface {
273 mi_decls = panic "No mi_decls in PIT",
274 mi_insts = panic "No mi_insts in PIT",
275 mi_fam_insts = panic "No mi_fam_insts in PIT",
276 mi_rules = panic "No mi_rules in PIT"
280 ; updateEps_ $ \ eps ->
282 eps_PIT = extendModuleEnv (eps_PIT eps) mod final_iface,
283 eps_PTE = addDeclsToPTE (eps_PTE eps) new_eps_decls,
284 eps_rule_base = extendRuleBaseList (eps_rule_base eps)
286 eps_inst_env = extendInstEnvList (eps_inst_env eps)
288 eps_fam_inst_env = extendFamInstEnvList (eps_fam_inst_env eps)
290 eps_vect_info = plusVectInfo (eps_vect_info eps)
295 extendFamInstEnvList emptyFamInstEnv
298 extendModuleEnv (eps_mod_fam_inst_env eps)
301 eps_stats = addEpsInStats (eps_stats eps)
302 (length new_eps_decls)
303 (length new_eps_insts)
304 (length new_eps_rules) }
306 ; return (Succeeded final_iface)
309 badDepMsg :: Module -> SDoc
311 = hang (ptext (sLit "Interface file inconsistency:"))
312 2 (sep [ptext (sLit "home-package module") <+> quotes (ppr mod) <+> ptext (sLit "is needed,"),
313 ptext (sLit "but is not listed in the dependencies of the interfaces directly imported by the module being compiled")])
315 -----------------------------------------------------
316 -- Loading type/class/value decls
317 -- We pass the full Module name here, replete with
318 -- its package info, so that we can build a Name for
319 -- each binder with the right package info in it
320 -- All subsequent lookups, including crucially lookups during typechecking
321 -- the declaration itself, will find the fully-glorious Name
323 -- We handle ATs specially. They are not main declarations, but also not
324 -- implict things (in particular, adding them to `implicitTyThings' would mess
325 -- things up in the renaming/type checking of source programs).
326 -----------------------------------------------------
328 addDeclsToPTE :: PackageTypeEnv -> [(Name,TyThing)] -> PackageTypeEnv
329 addDeclsToPTE pte things = extendNameEnvList pte things
332 -> [(Fingerprint, IfaceDecl)]
333 -> IfL [(Name,TyThing)]
334 loadDecls ignore_prags ver_decls
335 = do { mod <- getIfModule
336 ; thingss <- mapM (loadDecl ignore_prags mod) ver_decls
337 ; return (concat thingss)
340 loadDecl :: Bool -- Don't load pragmas into the decl pool
342 -> (Fingerprint, IfaceDecl)
343 -> IfL [(Name,TyThing)] -- The list can be poked eagerly, but the
344 -- TyThings are forkM'd thunks
345 loadDecl ignore_prags mod (_version, decl)
346 = do { -- Populate the name cache with final versions of all
347 -- the names associated with the decl
348 main_name <- lookupOrig mod (ifName decl)
349 -- ; traceIf (text "Loading decl for " <> ppr main_name)
350 ; implicit_names <- mapM (lookupOrig mod) (ifaceDeclSubBndrs decl)
352 -- Typecheck the thing, lazily
353 -- NB. Firstly, the laziness is there in case we never need the
354 -- declaration (in one-shot mode), and secondly it is there so that
355 -- we don't look up the occurrence of a name before calling mk_new_bndr
356 -- on the binder. This is important because we must get the right name
357 -- which includes its nameParent.
359 ; thing <- forkM doc $ do { bumpDeclStats main_name
360 ; tcIfaceDecl ignore_prags decl }
362 -- Populate the type environment with the implicitTyThings too.
364 -- Note [Tricky iface loop]
365 -- ~~~~~~~~~~~~~~~~~~~~~~~~
366 -- Summary: The delicate point here is that 'mini-env' must be
367 -- buildable from 'thing' without demanding any of the things
368 -- 'forkM'd by tcIfaceDecl.
370 -- In more detail: Consider the example
371 -- data T a = MkT { x :: T a }
372 -- The implicitTyThings of T are: [ <datacon MkT>, <selector x>]
373 -- (plus their workers, wrappers, coercions etc etc)
375 -- We want to return an environment
376 -- [ "MkT" -> <datacon MkT>, "x" -> <selector x>, ... ]
377 -- (where the "MkT" is the *Name* associated with MkT, etc.)
379 -- We do this by mapping the implict_names to the associated
380 -- TyThings. By the invariant on ifaceDeclSubBndrs and
381 -- implicitTyThings, we can use getOccName on the implicit
382 -- TyThings to make this association: each Name's OccName should
383 -- be the OccName of exactly one implictTyThing. So the key is
384 -- to define a "mini-env"
386 -- [ 'MkT' -> <datacon MkT>, 'x' -> <selector x>, ... ]
387 -- where the 'MkT' here is the *OccName* associated with MkT.
389 -- However, there is a subtlety: due to how type checking needs
390 -- to be staged, we can't poke on the forkM'd thunks inside the
391 -- implictTyThings while building this mini-env.
392 -- If we poke these thunks too early, two problems could happen:
393 -- (1) When processing mutually recursive modules across
394 -- hs-boot boundaries, poking too early will do the
395 -- type-checking before the recursive knot has been tied,
396 -- so things will be type-checked in the wrong
397 -- environment, and necessary variables won't be in
400 -- (2) Looking up one OccName in the mini_env will cause
401 -- others to be looked up, which might cause that
402 -- original one to be looked up again, and hence loop.
404 -- The code below works because of the following invariant:
405 -- getOccName on a TyThing does not force the suspended type
406 -- checks in order to extract the name. For example, we don't
407 -- poke on the "T a" type of <selector x> on the way to
408 -- extracting <selector x>'s OccName. Of course, there is no
409 -- reason in principle why getting the OccName should force the
410 -- thunks, but this means we need to be careful in
411 -- implicitTyThings and its helper functions.
413 -- All a bit too finely-balanced for my liking.
415 -- This mini-env and lookup function mediates between the
416 --'Name's n and the map from 'OccName's to the implicit TyThings
417 ; let mini_env = mkOccEnv [(getOccName t, t) | t <- implicitTyThings thing]
418 lookup n = case lookupOccEnv mini_env (getOccName n) of
421 pprPanic "loadDecl" (ppr main_name <+> ppr n $$ ppr (decl))
423 ; return $ (main_name, thing) :
424 -- uses the invariant that implicit_names and
425 -- implictTyThings are bijective
426 [(n, lookup n) | n <- implicit_names]
429 doc = ptext (sLit "Declaration for") <+> ppr (ifName decl)
431 bumpDeclStats :: Name -> IfL () -- Record that one more declaration has actually been used
433 = do { traceIf (text "Loading decl for" <+> ppr name)
434 ; updateEps_ (\eps -> let stats = eps_stats eps
435 in eps { eps_stats = stats { n_decls_out = n_decls_out stats + 1 } })
440 %*********************************************************
442 \subsection{Reading an interface file}
444 %*********************************************************
447 findAndReadIface :: SDoc -> Module
448 -> IsBootInterface -- True <=> Look for a .hi-boot file
449 -- False <=> Look for .hi file
450 -> TcRnIf gbl lcl (MaybeErr Message (ModIface, FilePath))
451 -- Nothing <=> file not found, or unreadable, or illegible
452 -- Just x <=> successfully found and parsed
454 -- It *doesn't* add an error to the monad, because
455 -- sometimes it's ok to fail... see notes with loadInterface
457 findAndReadIface doc_str mod hi_boot_file
458 = do { traceIf (sep [hsep [ptext (sLit "Reading"),
460 then ptext (sLit "[boot]")
462 ptext (sLit "interface for"),
464 nest 4 (ptext (sLit "reason:") <+> doc_str)])
466 -- Check for GHC.Prim, and return its static interface
469 then return (Succeeded (ghcPrimIface,
470 "<built in interface for GHC.Prim>"))
474 ; hsc_env <- getTopEnv
475 ; mb_found <- liftIO (findExactModule hsc_env mod)
480 -- Found file, so read it
481 { let { file_path = addBootSuffix_maybe hi_boot_file (ml_hi_file loc) }
483 ; if thisPackage dflags == modulePackageId mod
484 && not (isOneShot (ghcMode dflags))
485 then return (Failed (homeModError mod loc))
488 ; traceIf (ptext (sLit "readIFace") <+> text file_path)
489 ; read_result <- readIface mod file_path hi_boot_file
490 ; case read_result of
491 Failed err -> return (Failed (badIfaceFile file_path err))
493 | mi_module iface /= mod ->
494 return (Failed (wrongIfaceModErr iface mod file_path))
496 return (Succeeded (iface, file_path))
497 -- Don't forget to fill in the package name...
500 { traceIf (ptext (sLit "...not found"))
502 ; return (Failed (cannotFindInterface dflags
503 (moduleName mod) err)) }
508 @readIface@ tries just the one file.
511 readIface :: Module -> FilePath -> IsBootInterface
512 -> TcRnIf gbl lcl (MaybeErr Message ModIface)
513 -- Failed err <=> file not found, or unreadable, or illegible
514 -- Succeeded iface <=> successfully found and parsed
516 readIface wanted_mod file_path _
517 = do { res <- tryMostM $
518 readBinIface CheckHiWay QuietBinIFaceReading file_path
521 | wanted_mod == actual_mod -> return (Succeeded iface)
522 | otherwise -> return (Failed err)
524 actual_mod = mi_module iface
525 err = hiModuleNameMismatchWarn wanted_mod actual_mod
527 Left exn -> return (Failed (text (showException exn)))
532 %*********************************************************
534 Wired-in interface for GHC.Prim
536 %*********************************************************
539 initExternalPackageState :: ExternalPackageState
540 initExternalPackageState
542 eps_is_boot = emptyUFM,
543 eps_PIT = emptyPackageIfaceTable,
544 eps_PTE = emptyTypeEnv,
545 eps_inst_env = emptyInstEnv,
546 eps_fam_inst_env = emptyFamInstEnv,
547 eps_rule_base = mkRuleBase builtinRules,
548 -- Initialise the EPS rule pool with the built-in rules
551 eps_vect_info = noVectInfo,
552 eps_stats = EpsStats { n_ifaces_in = 0, n_decls_in = 0, n_decls_out = 0
553 , n_insts_in = 0, n_insts_out = 0
554 , n_rules_in = length builtinRules, n_rules_out = 0 }
559 %*********************************************************
561 Wired-in interface for GHC.Prim
563 %*********************************************************
566 ghcPrimIface :: ModIface
568 = (emptyModIface gHC_PRIM) {
569 mi_exports = [(gHC_PRIM, ghcPrimExports)],
571 mi_fixities = fixities,
572 mi_fix_fn = mkIfaceFixCache fixities
575 fixities = [(getOccName seqId, Fixity 0 InfixR)]
579 %*********************************************************
581 \subsection{Statistics}
583 %*********************************************************
586 ifaceStats :: ExternalPackageState -> SDoc
588 = hcat [text "Renamer stats: ", msg]
590 stats = eps_stats eps
592 [int (n_ifaces_in stats) <+> text "interfaces read",
593 hsep [ int (n_decls_out stats), text "type/class/variable imported, out of",
594 int (n_decls_in stats), text "read"],
595 hsep [ int (n_insts_out stats), text "instance decls imported, out of",
596 int (n_insts_in stats), text "read"],
597 hsep [ int (n_rules_out stats), text "rule decls imported, out of",
598 int (n_rules_in stats), text "read"]
603 %************************************************************************
607 %************************************************************************
610 -- | Read binary interface, and print it out
611 showIface :: HscEnv -> FilePath -> IO ()
612 showIface hsc_env filename = do
613 -- skip the hi way check; we don't want to worry about profiled vs.
614 -- non-profiled interfaces, for example.
615 iface <- initTcRnIf 's' hsc_env () () $
616 readBinIface IgnoreHiWay TraceBinIFaceReading filename
617 printDump (pprModIface iface)
621 pprModIface :: ModIface -> SDoc
624 = vcat [ ptext (sLit "interface")
625 <+> ppr (mi_module iface) <+> pp_boot
626 <+> (if mi_orphan iface then ptext (sLit "[orphan module]") else empty)
627 <+> (if mi_finsts iface then ptext (sLit "[family instance module]") else empty)
628 <+> (if mi_hpc iface then ptext (sLit "[hpc]") else empty)
629 <+> integer opt_HiVersion
630 , nest 2 (text "interface hash:" <+> ppr (mi_iface_hash iface))
631 , nest 2 (text "ABI hash:" <+> ppr (mi_mod_hash iface))
632 , nest 2 (text "export-list hash:" <+> ppr (mi_exp_hash iface))
633 , nest 2 (text "orphan hash:" <+> ppr (mi_orphan_hash iface))
634 , nest 2 (ptext (sLit "where"))
635 , vcat (map pprExport (mi_exports iface))
636 , pprDeps (mi_deps iface)
637 , vcat (map pprUsage (mi_usages iface))
638 , pprFixities (mi_fixities iface)
639 , vcat (map pprIfaceDecl (mi_decls iface))
640 , vcat (map ppr (mi_insts iface))
641 , vcat (map ppr (mi_fam_insts iface))
642 , vcat (map ppr (mi_rules iface))
643 , pprVectInfo (mi_vect_info iface)
644 , ppr (mi_warns iface)
647 pp_boot | mi_boot iface = ptext (sLit "[boot]")
651 When printing export lists, we print like this:
653 AvailTC C [C, x, y] C(x,y)
654 AvailTC C [x, y] C!(x,y) -- Exporting x, y but not C
657 pprExport :: IfaceExport -> SDoc
658 pprExport (mod, items)
659 = hsep [ ptext (sLit "export"), ppr mod, hsep (map pp_avail items) ]
661 pp_avail :: GenAvailInfo OccName -> SDoc
662 pp_avail (Avail occ) = ppr occ
663 pp_avail (AvailTC _ []) = empty
664 pp_avail (AvailTC n (n':ns))
665 | n==n' = ppr n <> pp_export ns
666 | otherwise = ppr n <> char '|' <> pp_export (n':ns)
669 pp_export names = braces (hsep (map ppr names))
671 pprUsage :: Usage -> SDoc
672 pprUsage usage@UsagePackageModule{}
673 = hsep [ptext (sLit "import"), ppr (usg_mod usage),
674 ppr (usg_mod_hash usage)]
675 pprUsage usage@UsageHomeModule{}
676 = hsep [ptext (sLit "import"), ppr (usg_mod_name usage),
677 ppr (usg_mod_hash usage)] $$
679 maybe empty (\v -> text "exports: " <> ppr v) (usg_exports usage) $$
680 vcat [ ppr n <+> ppr v | (n,v) <- usg_entities usage ]
683 pprDeps :: Dependencies -> SDoc
684 pprDeps (Deps { dep_mods = mods, dep_pkgs = pkgs, dep_orphs = orphs,
685 dep_finsts = finsts })
686 = vcat [ptext (sLit "module dependencies:") <+> fsep (map ppr_mod mods),
687 ptext (sLit "package dependencies:") <+> fsep (map ppr pkgs),
688 ptext (sLit "orphans:") <+> fsep (map ppr orphs),
689 ptext (sLit "family instance modules:") <+> fsep (map ppr finsts)
692 ppr_mod (mod_name, boot) = ppr mod_name <+> ppr_boot boot
693 ppr_boot True = text "[boot]"
694 ppr_boot False = empty
696 pprIfaceDecl :: (Fingerprint, IfaceDecl) -> SDoc
697 pprIfaceDecl (ver, decl)
698 = ppr ver $$ nest 2 (ppr decl)
700 pprFixities :: [(OccName, Fixity)] -> SDoc
701 pprFixities [] = empty
702 pprFixities fixes = ptext (sLit "fixities") <+> pprWithCommas pprFix fixes
704 pprFix (occ,fix) = ppr fix <+> ppr occ
706 pprVectInfo :: IfaceVectInfo -> SDoc
707 pprVectInfo (IfaceVectInfo { ifaceVectInfoVar = vars
708 , ifaceVectInfoTyCon = tycons
709 , ifaceVectInfoTyConReuse = tyconsReuse
712 [ ptext (sLit "vectorised variables:") <+> hsep (map ppr vars)
713 , ptext (sLit "vectorised tycons:") <+> hsep (map ppr tycons)
714 , ptext (sLit "vectorised reused tycons:") <+> hsep (map ppr tyconsReuse)
717 instance Outputable Warnings where
720 pprWarns :: Warnings -> SDoc
721 pprWarns NoWarnings = empty
722 pprWarns (WarnAll txt) = ptext (sLit "Warn all") <+> ppr txt
723 pprWarns (WarnSome prs) = ptext (sLit "Warnings")
724 <+> vcat (map pprWarning prs)
725 where pprWarning (name, txt) = ppr name <+> ppr txt
729 %*********************************************************
733 %*********************************************************
736 badIfaceFile :: String -> SDoc -> SDoc
737 badIfaceFile file err
738 = vcat [ptext (sLit "Bad interface file:") <+> text file,
741 hiModuleNameMismatchWarn :: Module -> Module -> Message
742 hiModuleNameMismatchWarn requested_mod read_mod =
743 withPprStyle defaultUserStyle $
744 -- we want the Modules below to be qualified with package names,
745 -- so reset the PrintUnqualified setting.
746 hsep [ ptext (sLit "Something is amiss; requested module ")
748 , ptext (sLit "differs from name found in the interface file")
752 wrongIfaceModErr :: ModIface -> Module -> String -> SDoc
753 wrongIfaceModErr iface mod_name file_path
754 = sep [ptext (sLit "Interface file") <+> iface_file,
755 ptext (sLit "contains module") <+> quotes (ppr (mi_module iface)) <> comma,
756 ptext (sLit "but we were expecting module") <+> quotes (ppr mod_name),
757 sep [ptext (sLit "Probable cause: the source code which generated"),
759 ptext (sLit "has an incompatible module name")
762 where iface_file = doubleQuotes (text file_path)
764 homeModError :: Module -> ModLocation -> SDoc
765 homeModError mod location
766 = ptext (sLit "attempting to use module ") <> quotes (ppr mod)
767 <> (case ml_hs_file location of
768 Just file -> space <> parens (text file)
770 <+> ptext (sLit "which is not loaded")