2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
4 \section{Dealing with interface files}
8 loadInterface, loadInterfaceForName, loadWiredInHomeIface,
9 loadSrcInterface, loadSysInterface, loadOrphanModules,
10 findAndReadIface, readIface, -- Used when reading the module's old interface
11 loadDecls, ifaceStats, discardDeclPrags,
12 initExternalPackageState,
14 pprModIface, showIface -- Print the iface in Foo.hi
17 #include "HsVersions.h"
19 import {-# SOURCE #-} TcIface( tcIfaceDecl, tcIfaceRule, tcIfaceInst )
21 import DynFlags ( DynFlags(..), DynFlag( Opt_IgnoreInterfacePragmas ) )
22 import IfaceSyn ( IfaceDecl(..), IfaceConDecl(..), IfaceClassOp(..),
23 IfaceConDecls(..), IfaceIdInfo(..) )
24 import IfaceEnv ( newGlobalBinder )
25 import HscTypes ( ModIface(..), TyThing, IfaceExport, Usage(..),
26 Deprecs(..), Dependencies(..),
27 emptyModIface, EpsStats(..), GenAvailInfo(..),
28 addEpsInStats, ExternalPackageState(..),
29 PackageTypeEnv, emptyTypeEnv, HscEnv(..),
30 lookupIfaceByModule, emptyPackageIfaceTable,
31 IsBootInterface, mkIfaceFixCache,
35 import BasicTypes ( Version, initialVersion,
36 Fixity(..), FixityDirection(..), isMarkedStrict )
38 import Type ( TyThing(..) )
39 import Class ( classATs )
41 import PrelNames ( gHC_PRIM )
42 import PrelInfo ( ghcPrimExports )
43 import PrelRules ( builtinRules )
44 import Rules ( extendRuleBaseList, mkRuleBase )
45 import InstEnv ( emptyInstEnv, extendInstEnvList )
46 import Name ( Name {-instance NamedThing-}, getOccName,
47 nameModule, nameIsLocalOrFrom, isWiredInName )
51 import OccName ( OccName, mkOccEnv, lookupOccEnv, mkClassTyConOcc,
52 mkClassDataConOcc, mkSuperDictSelOcc,
53 mkDataConWrapperOcc, mkDataConWorkerOcc,
54 mkNewTyCoOcc, mkInstTyTcOcc, mkInstTyCoOcc )
55 import SrcLoc ( importedSrcLoc )
56 import Maybes ( MaybeErr(..) )
57 import ErrUtils ( Message )
58 import Finder ( findImportedModule, findExactModule,
59 FindResult(..), cannotFindInterface )
61 import StaticFlags ( opt_HiVersion )
63 import BinIface ( readBinIface, v_IgnoreHiWay )
64 import Binary ( getBinFileWithDict )
65 import Panic ( ghcError, tryMost, showException, GhcException(..) )
67 import Maybe ( isJust )
68 import DATA_IOREF ( writeIORef )
72 %************************************************************************
74 loadSrcInterface, loadOrphanModules, loadHomeInterface
76 These three are called from TcM-land
78 %************************************************************************
81 -- | Load the interface corresponding to an @import@ directive in
82 -- source code. On a failure, fail in the monad with an error message.
83 loadSrcInterface :: SDoc -> ModuleName -> IsBootInterface -> RnM ModIface
84 loadSrcInterface doc mod want_boot = do
85 -- We must first find which Module this import refers to. This involves
86 -- calling the Finder, which as a side effect will search the filesystem
87 -- and create a ModLocation. If successful, loadIface will read the
88 -- interface; it will call the Finder again, but the ModLocation will be
89 -- cached from the first search.
91 res <- ioToIOEnv $ findImportedModule hsc_env mod Nothing
94 mb_iface <- initIfaceTcRn $ loadInterface doc mod (ImportByUser want_boot)
96 Failed err -> failWithTc err
97 Succeeded iface -> return iface
99 let dflags = hsc_dflags hsc_env in
100 failWithTc (cannotFindInterface dflags mod err)
102 -- | Load interfaces for a collection of orphan modules.
103 loadOrphanModules :: [Module] -> TcM ()
104 loadOrphanModules mods
105 | null mods = returnM ()
106 | otherwise = initIfaceTcRn $
107 do { traceIf (text "Loading orphan modules:" <+>
112 load mod = loadSysInterface (mk_doc mod) mod
113 mk_doc mod = ppr mod <+> ptext SLIT("is a orphan-instance module")
115 -- | Loads the interface for a given Name.
116 loadInterfaceForName :: SDoc -> Name -> TcRn ModIface
117 loadInterfaceForName doc name
120 -- Should not be called with a name from the module being compiled
121 this_mod <- getModule
122 ; ASSERT2( not (nameIsLocalOrFrom this_mod name), ppr name <+> parens doc )
124 initIfaceTcRn $ loadSysInterface doc (nameModule name)
127 -- | An 'IfM' function to load the home interface for a wired-in thing,
128 -- so that we're sure that we see its instance declarations and rules
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 }
146 %*********************************************************
150 The main function to load an interface
151 for an imported module, and put it in
152 the External Package State
154 %*********************************************************
157 loadInterface :: SDoc -> Module -> WhereFrom
158 -> IfM lcl (MaybeErr Message ModIface)
160 -- If it can't find a suitable interface file, we
161 -- a) modify the PackageIfaceTable to have an empty entry
162 -- (to avoid repeated complaints)
163 -- b) return (Left message)
165 -- It's not necessarily an error for there not to be an interface
166 -- file -- perhaps the module has changed, and that interface
169 loadInterface doc_str mod from
170 = do { -- Read the state
171 (eps,hpt) <- getEpsAndHpt
173 ; traceIf (text "Considering whether to load" <+> ppr mod <+> ppr from)
175 -- Check whether we have the interface already
177 ; case lookupIfaceByModule dflags hpt (eps_PIT eps) mod of {
179 -> returnM (Succeeded iface) ; -- Already loaded
180 -- The (src_imp == mi_boot iface) test checks that the already-loaded
181 -- interface isn't a boot iface. This can conceivably happen,
182 -- if an earlier import had a before we got to real imports. I think.
185 { let { hi_boot_file = case from of
186 ImportByUser usr_boot -> usr_boot
187 ImportBySystem -> sys_boot
189 ; mb_dep = lookupUFM (eps_is_boot eps) (moduleName mod)
190 ; sys_boot = case mb_dep of
191 Just (_, is_boot) -> is_boot
193 -- The boot-ness of the requested interface,
194 } -- based on the dependencies in directly-imported modules
196 -- READ THE MODULE IN
197 ; read_result <- findAndReadIface doc_str mod hi_boot_file
199 ; case read_result of {
201 { let fake_iface = emptyModIface mod
203 ; updateEps_ $ \eps ->
204 eps { eps_PIT = extendModuleEnv (eps_PIT eps) (mi_module fake_iface) fake_iface }
205 -- Not found, so add an empty iface to
206 -- the EPS map so that we don't look again
208 ; returnM (Failed err) } ;
211 Succeeded (iface, file_path) -- Sanity check:
212 | ImportBySystem <- from, -- system-importing...
213 modulePackageId (mi_module iface) == thisPackage dflags,
214 -- a home-package module...
215 Nothing <- mb_dep -- that we know nothing about
216 -> returnM (Failed (badDepMsg mod))
221 loc_doc = text file_path
223 initIfaceLcl mod loc_doc $ do
225 -- Load the new ModIface into the External Package State
226 -- Even home-package interfaces loaded by loadInterface
227 -- (which only happens in OneShot mode; in Batch/Interactive
228 -- mode, home-package modules are loaded one by one into the HPT)
229 -- are put in the EPS.
231 -- The main thing is to add the ModIface to the PIT, but
233 -- IfaceDecls, IfaceInst, IfaceRules
234 -- out of the ModIface and put them into the big EPS pools
236 -- NB: *first* we do loadDecl, so that the provenance of all the locally-defined
237 --- names is done correctly (notably, whether this is an .hi file or .hi-boot file).
238 -- If we do loadExport first the wrong info gets into the cache (unless we
239 -- explicitly tag each export which seems a bit of a bore)
241 ; ignore_prags <- doptM Opt_IgnoreInterfacePragmas
242 ; new_eps_decls <- loadDecls ignore_prags (mi_decls iface)
243 ; new_eps_insts <- mapM tcIfaceInst (mi_insts iface)
244 ; new_eps_rules <- if ignore_prags
246 else mapM tcIfaceRule (mi_rules iface)
248 ; let { final_iface = iface { mi_decls = panic "No mi_decls in PIT",
249 mi_insts = panic "No mi_insts in PIT",
250 mi_rules = panic "No mi_rules in PIT" } }
252 ; updateEps_ $ \ eps ->
253 eps { eps_PIT = extendModuleEnv (eps_PIT eps) mod final_iface,
254 eps_PTE = addDeclsToPTE (eps_PTE eps) new_eps_decls,
255 eps_rule_base = extendRuleBaseList (eps_rule_base eps) new_eps_rules,
256 eps_inst_env = extendInstEnvList (eps_inst_env eps) new_eps_insts,
257 eps_stats = addEpsInStats (eps_stats eps) (length new_eps_decls)
258 (length new_eps_insts) (length new_eps_rules) }
260 ; return (Succeeded final_iface)
264 = hang (ptext SLIT("Interface file inconsistency:"))
265 2 (sep [ptext SLIT("home-package module") <+> quotes (ppr mod) <+> ptext SLIT("is mentioned,"),
266 ptext SLIT("but does not appear in the dependencies of the interface")])
268 -----------------------------------------------------
269 -- Loading type/class/value decls
270 -- We pass the full Module name here, replete with
271 -- its package info, so that we can build a Name for
272 -- each binder with the right package info in it
273 -- All subsequent lookups, including crucially lookups during typechecking
274 -- the declaration itself, will find the fully-glorious Name
276 -- We handle ATs specially. They are not main declarations, but also not
277 -- implict things (in particular, adding them to `implicitTyThings' would mess
278 -- things up in the renaming/type checking of source programs).
279 -----------------------------------------------------
281 addDeclsToPTE :: PackageTypeEnv -> [(Name,TyThing)] -> PackageTypeEnv
282 addDeclsToPTE pte things = extendNameEnvList pte things
285 -> [(Version, IfaceDecl)]
286 -> IfL [(Name,TyThing)]
287 loadDecls ignore_prags ver_decls
288 = do { mod <- getIfModule
289 ; thingss <- mapM (loadDecl ignore_prags mod) ver_decls
290 ; return (concat thingss)
293 loadDecl :: Bool -- Don't load pragmas into the decl pool
295 -> (Version, IfaceDecl)
296 -> IfL [(Name,TyThing)] -- The list can be poked eagerly, but the
297 -- TyThings are forkM'd thunks
298 loadDecl ignore_prags mod (_version, decl)
299 = do { -- Populate the name cache with final versions of all
300 -- the names associated with the decl
301 main_name <- mk_new_bndr mod Nothing (ifName decl)
302 ; implicit_names <- mapM (mk_new_bndr mod (Just main_name))
303 (ifaceDeclSubBndrs decl)
305 -- Typecheck the thing, lazily
306 -- NB. firstly, the laziness is there in case we never need the
307 -- declaration (in one-shot mode), and secondly it is there so that
308 -- we don't look up the occurrence of a name before calling mk_new_bndr
309 -- on the binder. This is important because we must get the right name
310 -- which includes its nameParent.
311 ; thing <- forkM doc (bumpDeclStats main_name >> tcIfaceDecl stripped_decl)
312 ; let mini_env = mkOccEnv [(getOccName t, t) | t <- implicitTyThings thing]
313 lookup n = case lookupOccEnv mini_env (getOccName n) of
316 pprPanic "loadDecl" (ppr main_name <+>
317 ppr n $$ ppr (stripped_decl))
319 ; returnM $ (main_name, thing) : [(n, lookup n) | n <- implicit_names]
321 -- We build a list from the *known* names, with (lookup n) thunks
322 -- as the TyThings. That way we can extend the PTE without poking the
325 stripped_decl | ignore_prags = discardDeclPrags decl
328 -- mk_new_bndr allocates in the name cache the final canonical
329 -- name for the thing, with the correct
332 -- imported name, to fix the module correctly in the cache
333 mk_new_bndr mod mb_parent occ
334 = newGlobalBinder mod occ mb_parent
335 (importedSrcLoc (showSDoc (ppr (moduleName mod))))
336 -- ToDo: qualify with the package name if necessary
338 doc = ptext SLIT("Declaration for") <+> ppr (ifName decl)
340 discardDeclPrags :: IfaceDecl -> IfaceDecl
341 discardDeclPrags decl@(IfaceId {ifIdInfo = HasInfo _}) = decl { ifIdInfo = NoInfo }
342 discardDeclPrags decl = decl
344 bumpDeclStats :: Name -> IfL () -- Record that one more declaration has actually been used
346 = do { traceIf (text "Loading decl for" <+> ppr name)
347 ; updateEps_ (\eps -> let stats = eps_stats eps
348 in eps { eps_stats = stats { n_decls_out = n_decls_out stats + 1 } })
352 ifaceDeclSubBndrs :: IfaceDecl -> [OccName]
353 -- *Excludes* the 'main' name, but *includes* the implicitly-bound names
354 -- Deeply revolting, because it has to predict what gets bound,
355 -- especially the question of whether there's a wrapper for a datacon
357 -- If you change this, make sure you change HscTypes.implicitTyThings in sync
359 ifaceDeclSubBndrs (IfaceClass {ifCtxt = sc_ctxt, ifName = cls_occ,
360 ifSigs = sigs, ifATs = ats })
362 [tc_occ, dc_occ, dcww_occ] ++
363 [op | IfaceClassOp op _ _ <- sigs] ++
364 [ifName at | at <- ats ] ++
365 [mkSuperDictSelOcc n cls_occ | n <- [1..n_ctxt]]
367 n_ctxt = length sc_ctxt
369 tc_occ = mkClassTyConOcc cls_occ
370 dc_occ = mkClassDataConOcc cls_occ
371 co_occs | is_newtype = [mkNewTyCoOcc tc_occ]
373 dcww_occ -- | is_newtype = mkDataConWrapperOcc dc_occ -- Newtypes have wrapper but no worker
374 | otherwise = mkDataConWorkerOcc dc_occ -- Otherwise worker but no wrapper
375 is_newtype = n_sigs + n_ctxt == 1 -- Sigh
377 ifaceDeclSubBndrs IfaceData {ifCons = IfAbstractTyCon}
380 ifaceDeclSubBndrs (IfaceData {ifName = tc_occ,
381 ifCons = IfNewTyCon (
382 IfCon { ifConOcc = con_occ,
385 ifFamInst = famInst})
386 = fields ++ [con_occ, mkDataConWorkerOcc con_occ, mkNewTyCoOcc tc_occ]
387 ++ famInstCo famInst tc_occ
389 ifaceDeclSubBndrs (IfaceData {ifName = tc_occ,
390 ifCons = IfDataTyCon cons,
391 ifFamInst = famInst})
392 = nub (concatMap ifConFields cons) -- Eliminate duplicate fields
393 ++ concatMap dc_occs cons
394 ++ famInstCo famInst tc_occ
397 | has_wrapper = [con_occ, work_occ, wrap_occ]
398 | otherwise = [con_occ, work_occ]
400 con_occ = ifConOcc con_decl
401 strs = ifConStricts con_decl
402 wrap_occ = mkDataConWrapperOcc con_occ
403 work_occ = mkDataConWorkerOcc con_occ
404 has_wrapper = any isMarkedStrict strs -- See MkId.mkDataConIds (sigh)
405 || not (null . ifConEqSpec $ con_decl)
407 -- ToDo: may miss strictness in existential dicts
409 ifaceDeclSubBndrs _other = []
411 -- coercion for data/newtype family instances
412 famInstCo Nothing baseOcc = []
413 famInstCo (Just (_, _, index)) baseOcc = [mkInstTyTcOcc index baseOcc,
414 mkInstTyCoOcc index baseOcc]
418 %*********************************************************
420 \subsection{Reading an interface file}
422 %*********************************************************
425 findAndReadIface :: SDoc -> Module
426 -> IsBootInterface -- True <=> Look for a .hi-boot file
427 -- False <=> Look for .hi file
428 -> TcRnIf gbl lcl (MaybeErr Message (ModIface, FilePath))
429 -- Nothing <=> file not found, or unreadable, or illegible
430 -- Just x <=> successfully found and parsed
432 -- It *doesn't* add an error to the monad, because
433 -- sometimes it's ok to fail... see notes with loadInterface
435 findAndReadIface doc_str mod hi_boot_file
436 = do { traceIf (sep [hsep [ptext SLIT("Reading"),
438 then ptext SLIT("[boot]")
440 ptext SLIT("interface for"),
442 nest 4 (ptext SLIT("reason:") <+> doc_str)])
444 -- Check for GHC.Prim, and return its static interface
447 then returnM (Succeeded (ghcPrimIface,
448 "<built in interface for GHC.Prim>"))
452 ; hsc_env <- getTopEnv
453 ; mb_found <- ioToIOEnv (findHiFile hsc_env mod hi_boot_file)
456 { traceIf (ptext SLIT("...not found"))
458 ; returnM (Failed (cannotFindInterface dflags
459 (moduleName mod) err)) } ;
461 Succeeded file_path -> do
463 -- Found file, so read it
464 { traceIf (ptext SLIT("readIFace") <+> text file_path)
465 ; read_result <- readIface mod file_path hi_boot_file
466 ; case read_result of
467 Failed err -> returnM (Failed (badIfaceFile file_path err))
469 | mi_module iface /= mod ->
470 return (Failed (wrongIfaceModErr iface mod file_path))
472 returnM (Succeeded (iface, file_path))
473 -- Don't forget to fill in the package name...
476 findHiFile :: HscEnv -> Module -> IsBootInterface
477 -> IO (MaybeErr FindResult FilePath)
478 findHiFile hsc_env mod hi_boot_file
480 maybe_found <- findExactModule hsc_env mod
482 Found loc mod -> return (Succeeded path)
484 path = addBootSuffix_maybe hi_boot_file (ml_hi_file loc)
485 err -> return (Failed err)
488 @readIface@ tries just the one file.
491 readIface :: Module -> FilePath -> IsBootInterface
492 -> TcRnIf gbl lcl (MaybeErr Message ModIface)
493 -- Failed err <=> file not found, or unreadable, or illegible
494 -- Succeeded iface <=> successfully found and parsed
496 readIface wanted_mod file_path is_hi_boot_file
497 = do { dflags <- getDOpts
499 { res <- tryMost (readBinIface file_path)
502 | wanted_mod == actual_mod -> return (Succeeded iface)
503 | otherwise -> return (Failed err)
505 actual_mod = mi_module iface
506 err = hiModuleNameMismatchWarn wanted_mod actual_mod
508 Left exn -> return (Failed (text (showException exn)))
513 %*********************************************************
515 Wired-in interface for GHC.Prim
517 %*********************************************************
520 initExternalPackageState :: ExternalPackageState
521 initExternalPackageState
523 eps_is_boot = emptyUFM,
524 eps_PIT = emptyPackageIfaceTable,
525 eps_PTE = emptyTypeEnv,
526 eps_inst_env = emptyInstEnv,
527 eps_rule_base = mkRuleBase builtinRules,
528 -- Initialise the EPS rule pool with the built-in rules
529 eps_stats = EpsStats { n_ifaces_in = 0, n_decls_in = 0, n_decls_out = 0
530 , n_insts_in = 0, n_insts_out = 0
531 , n_rules_in = length builtinRules, n_rules_out = 0 }
536 %*********************************************************
538 Wired-in interface for GHC.Prim
540 %*********************************************************
543 ghcPrimIface :: ModIface
545 = (emptyModIface gHC_PRIM) {
546 mi_exports = [(gHC_PRIM, ghcPrimExports)],
548 mi_fixities = fixities,
549 mi_fix_fn = mkIfaceFixCache fixities
552 fixities = [(getOccName seqId, Fixity 0 InfixR)]
556 %*********************************************************
558 \subsection{Statistics}
560 %*********************************************************
563 ifaceStats :: ExternalPackageState -> SDoc
565 = hcat [text "Renamer stats: ", msg]
567 stats = eps_stats eps
569 [int (n_ifaces_in stats) <+> text "interfaces read",
570 hsep [ int (n_decls_out stats), text "type/class/variable imported, out of",
571 int (n_decls_in stats), text "read"],
572 hsep [ int (n_insts_out stats), text "instance decls imported, out of",
573 int (n_insts_in stats), text "read"],
574 hsep [ int (n_rules_out stats), text "rule decls imported, out of",
575 int (n_rules_in stats), text "read"]
580 %************************************************************************
584 %************************************************************************
587 showIface :: FilePath -> IO ()
588 -- Read binary interface, and print it out
589 showIface filename = do
590 -- skip the version check; we don't want to worry about profiled vs.
591 -- non-profiled interfaces, for example.
592 writeIORef v_IgnoreHiWay True
593 iface <- Binary.getBinFileWithDict filename
594 printDump (pprModIface iface)
600 pprModIface :: ModIface -> SDoc
603 = vcat [ ptext SLIT("interface")
604 <+> ppr (mi_module iface) <+> pp_boot
605 <+> ppr (mi_mod_vers iface) <+> pp_sub_vers
606 <+> (if mi_orphan iface then ptext SLIT("[orphan module]") else empty)
607 <+> int opt_HiVersion
608 <+> ptext SLIT("where")
609 , vcat (map pprExport (mi_exports iface))
610 , pprDeps (mi_deps iface)
611 , vcat (map pprUsage (mi_usages iface))
612 , pprFixities (mi_fixities iface)
613 , vcat (map pprIfaceDecl (mi_decls iface))
614 , vcat (map ppr (mi_insts iface))
615 , vcat (map ppr (mi_rules iface))
616 , pprDeprecs (mi_deprecs iface)
619 pp_boot | mi_boot iface = ptext SLIT("[boot]")
622 exp_vers = mi_exp_vers iface
623 rule_vers = mi_rule_vers iface
625 pp_sub_vers | exp_vers == initialVersion && rule_vers == initialVersion = empty
626 | otherwise = brackets (ppr exp_vers <+> ppr rule_vers)
629 When printing export lists, we print like this:
631 AvailTC C [C, x, y] C(x,y)
632 AvailTC C [x, y] C!(x,y) -- Exporting x, y but not C
635 pprExport :: IfaceExport -> SDoc
636 pprExport (mod, items)
637 = hsep [ ptext SLIT("export"), ppr mod, hsep (map pp_avail items) ]
639 pp_avail :: GenAvailInfo OccName -> SDoc
640 pp_avail (Avail occ) = ppr occ
641 pp_avail (AvailTC _ []) = empty
642 pp_avail (AvailTC n (n':ns))
643 | n==n' = ppr n <> pp_export ns
644 | otherwise = ppr n <> char '|' <> pp_export (n':ns)
647 pp_export names = braces (hsep (map ppr names))
649 pprUsage :: Usage -> SDoc
651 = hsep [ptext SLIT("import"), ppr (usg_name usage),
653 pp_export_version (usg_exports usage),
654 int (usg_rules usage),
655 pp_versions (usg_entities usage) ]
657 pp_versions nvs = hsep [ ppr n <+> int v | (n,v) <- nvs ]
658 pp_export_version Nothing = empty
659 pp_export_version (Just v) = int v
661 pprDeps :: Dependencies -> SDoc
662 pprDeps (Deps { dep_mods = mods, dep_pkgs = pkgs, dep_orphs = orphs})
663 = vcat [ptext SLIT("module dependencies:") <+> fsep (map ppr_mod mods),
664 ptext SLIT("package dependencies:") <+> fsep (map ppr pkgs),
665 ptext SLIT("orphans:") <+> fsep (map ppr orphs)
668 ppr_mod (mod_name, boot) = ppr mod_name <+> ppr_boot boot
669 ppr_boot True = text "[boot]"
670 ppr_boot False = empty
672 pprIfaceDecl :: (Version, IfaceDecl) -> SDoc
673 pprIfaceDecl (ver, decl)
674 = ppr_vers ver <+> ppr decl
676 -- Print the version for the decl
677 ppr_vers v | v == initialVersion = empty
680 pprFixities :: [(OccName, Fixity)] -> SDoc
681 pprFixities [] = empty
682 pprFixities fixes = ptext SLIT("fixities") <+> pprWithCommas pprFix fixes
684 pprFix (occ,fix) = ppr fix <+> ppr occ
686 pprDeprecs NoDeprecs = empty
687 pprDeprecs (DeprecAll txt) = ptext SLIT("Deprecate all") <+> doubleQuotes (ftext txt)
688 pprDeprecs (DeprecSome prs) = ptext SLIT("Deprecate") <+> vcat (map pprDeprec prs)
690 pprDeprec (name, txt) = ppr name <+> doubleQuotes (ftext txt)
694 %*********************************************************
698 %*********************************************************
701 badIfaceFile file err
702 = vcat [ptext SLIT("Bad interface file:") <+> text file,
705 hiModuleNameMismatchWarn :: Module -> Module -> Message
706 hiModuleNameMismatchWarn requested_mod read_mod =
707 withPprStyle defaultUserStyle $
708 -- we want the Modules below to be qualified with package names,
709 -- so reset the PrintUnqualified setting.
710 hsep [ ptext SLIT("Something is amiss; requested module ")
712 , ptext SLIT("differs from name found in the interface file")
716 wrongIfaceModErr iface mod_name file_path
717 = sep [ptext SLIT("Interface file") <+> iface_file,
718 ptext SLIT("contains module") <+> quotes (ppr (mi_module iface)) <> comma,
719 ptext SLIT("but we were expecting module") <+> quotes (ppr mod_name),
720 sep [ptext SLIT("Probable cause: the source code which generated"),
722 ptext SLIT("has an incompatible module name")
725 where iface_file = doubleQuotes (text file_path)