don't qualify module name for importedSrcLoc
[ghc-hetmet.git] / compiler / iface / LoadIface.lhs
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
3 %
4 \section{Dealing with interface files}
5
6 \begin{code}
7 module LoadIface (
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
13    ) where
14
15 #include "HsVersions.h"
16
17 import {-# SOURCE #-}   TcIface( tcIfaceDecl, tcIfaceRule, tcIfaceInst )
18
19 import DynFlags         ( DynFlags(..), DynFlag( Opt_IgnoreInterfacePragmas ) )
20 import IfaceSyn         ( IfaceDecl(..), IfaceConDecl(..), IfaceClassOp(..),
21                           IfaceConDecls(..), IfaceIdInfo(..) )
22 import IfaceEnv         ( newGlobalBinder )
23 import HscTypes         ( ModIface(..), TyThing, emptyModIface, EpsStats(..),
24                           addEpsInStats, ExternalPackageState(..),
25                           PackageTypeEnv, emptyTypeEnv,  HscEnv(..),
26                           lookupIfaceByModule, emptyPackageIfaceTable,
27                           IsBootInterface, mkIfaceFixCache, 
28                           implicitTyThings 
29                          )
30
31 import BasicTypes       ( Version, Fixity(..), FixityDirection(..),
32                           isMarkedStrict )
33 import TcRnMonad
34
35 import PrelNames        ( gHC_PRIM )
36 import PrelInfo         ( ghcPrimExports )
37 import PrelRules        ( builtinRules )
38 import Rules            ( extendRuleBaseList, mkRuleBase )
39 import InstEnv          ( emptyInstEnv, extendInstEnvList )
40 import Name             ( Name {-instance NamedThing-}, getOccName,
41                           nameModule, nameIsLocalOrFrom, isWiredInName )
42 import NameEnv
43 import MkId             ( seqId )
44 import Module
45 import OccName          ( OccName, mkOccEnv, lookupOccEnv, mkClassTyConOcc, mkClassDataConOcc,
46                           mkSuperDictSelOcc, mkDataConWrapperOcc, mkDataConWorkerOcc )
47 import SrcLoc           ( importedSrcLoc )
48 import Maybes           ( MaybeErr(..) )
49 import ErrUtils         ( Message )
50 import Finder           ( findImportedModule, findExactModule,  
51                           FindResult(..), cantFindError )
52 import UniqFM
53 import Outputable
54 import BinIface         ( readBinIface )
55 import Panic            ( ghcError, tryMost, showException, GhcException(..) )
56 import List             ( nub )
57 \end{code}
58
59
60 %************************************************************************
61 %*                                                                      *
62         loadSrcInterface, loadOrphanModules, loadHomeInterface
63
64                 These three are called from TcM-land    
65 %*                                                                      *
66 %************************************************************************
67
68 \begin{code}
69 -- | Load the interface corresponding to an @import@ directive in 
70 -- source code.  On a failure, fail in the monad with an error message.
71 loadSrcInterface :: SDoc -> ModuleName -> IsBootInterface -> RnM ModIface
72 loadSrcInterface doc mod want_boot  = do        
73   -- We must first find which Module this import refers to.  This involves
74   -- calling the Finder, which as a side effect will search the filesystem
75   -- and create a ModLocation.  If successful, loadIface will read the
76   -- interface; it will call the Finder again, but the ModLocation will be
77   -- cached from the first search.
78   hsc_env <- getTopEnv
79   res <- ioToIOEnv $ findImportedModule hsc_env mod Nothing
80   case res of
81     Found _ mod -> do
82       mb_iface <- initIfaceTcRn $ loadInterface doc mod (ImportByUser want_boot)
83       case mb_iface of
84         Failed err      -> failWithTc (elaborate err)
85         Succeeded iface -> return iface
86     err ->
87         let dflags = hsc_dflags hsc_env in
88         failWithTc (elaborate (cantFindError dflags mod err))
89   where
90     elaborate err = hang (ptext SLIT("Failed to load interface for") <+> 
91                           quotes (ppr mod) <> colon) 4 err
92
93 -- | Load interfaces for a collection of orphan modules.
94 loadOrphanModules :: [Module] -> TcM ()
95 loadOrphanModules mods
96   | null mods = returnM ()
97   | otherwise = initIfaceTcRn $
98                 do { traceIf (text "Loading orphan modules:" <+> 
99                                  fsep (map ppr mods))
100                    ; mappM_ load mods
101                    ; returnM () }
102   where
103     load mod   = loadSysInterface (mk_doc mod) mod
104     mk_doc mod = ppr mod <+> ptext SLIT("is a orphan-instance module")
105
106 -- | Loads the interface for a given Name.
107 loadInterfaceForName :: SDoc -> Name -> TcRn ModIface
108 loadInterfaceForName doc name
109   = do  { 
110 #ifdef DEBUG
111                 -- Should not be called with a name from the module being compiled
112           this_mod <- getModule
113         ; ASSERT2( not (nameIsLocalOrFrom this_mod name), ppr name <+> parens doc )
114 #endif
115           initIfaceTcRn $ loadSysInterface doc (nameModule name)
116     }
117
118 -- | An 'IfM' function to load the home interface for a wired-in thing,
119 -- so that we're sure that we see its instance declarations and rules
120 loadWiredInHomeIface :: Name -> IfM lcl ()
121 loadWiredInHomeIface name
122   = ASSERT( isWiredInName name )
123     do loadSysInterface doc (nameModule name); return ()
124   where
125     doc = ptext SLIT("Need home interface for wired-in thing") <+> ppr name
126
127 -- | A wrapper for 'loadInterface' that throws an exception if it fails
128 loadSysInterface :: SDoc -> Module -> IfM lcl ModIface
129 loadSysInterface doc mod_name
130   = do  { mb_iface <- loadInterface doc mod_name ImportBySystem
131         ; case mb_iface of 
132             Failed err      -> ghcError (ProgramError (showSDoc err))
133             Succeeded iface -> return iface }
134 \end{code}
135
136
137 %*********************************************************
138 %*                                                      *
139                 loadInterface
140
141         The main function to load an interface
142         for an imported module, and put it in
143         the External Package State
144 %*                                                      *
145 %*********************************************************
146
147 \begin{code}
148 loadInterface :: SDoc -> Module -> WhereFrom
149               -> IfM lcl (MaybeErr Message ModIface)
150
151 -- If it can't find a suitable interface file, we
152 --      a) modify the PackageIfaceTable to have an empty entry
153 --              (to avoid repeated complaints)
154 --      b) return (Left message)
155 --
156 -- It's not necessarily an error for there not to be an interface
157 -- file -- perhaps the module has changed, and that interface 
158 -- is no longer used
159
160 loadInterface doc_str mod from
161   = do  {       -- Read the state
162           (eps,hpt) <- getEpsAndHpt
163
164         ; traceIf (text "Considering whether to load" <+> ppr mod <+> ppr from)
165
166                 -- Check whether we have the interface already
167         ; dflags <- getDOpts
168         ; case lookupIfaceByModule dflags hpt (eps_PIT eps) mod of {
169             Just iface 
170                 -> returnM (Succeeded iface) ;  -- Already loaded
171                         -- The (src_imp == mi_boot iface) test checks that the already-loaded
172                         -- interface isn't a boot iface.  This can conceivably happen,
173                         -- if an earlier import had a before we got to real imports.   I think.
174             other -> do
175
176         { let { hi_boot_file = case from of
177                                 ImportByUser usr_boot -> usr_boot
178                                 ImportBySystem        -> sys_boot
179
180               ; mb_dep   = lookupUFM (eps_is_boot eps) (moduleName mod)
181               ; sys_boot = case mb_dep of
182                                 Just (_, is_boot) -> is_boot
183                                 Nothing           -> False
184                         -- The boot-ness of the requested interface, 
185               }         -- based on the dependencies in directly-imported modules
186
187         -- READ THE MODULE IN
188         ; read_result <- findAndReadIface doc_str mod hi_boot_file
189         ; dflags <- getDOpts
190         ; case read_result of {
191             Failed err -> do
192                 { let fake_iface = emptyModIface mod
193
194                 ; updateEps_ $ \eps ->
195                         eps { eps_PIT = extendModuleEnv (eps_PIT eps) (mi_module fake_iface) fake_iface }
196                         -- Not found, so add an empty iface to 
197                         -- the EPS map so that we don't look again
198                                 
199                 ; returnM (Failed err) } ;
200
201         -- Found and parsed!
202             Succeeded (iface, file_path)                        -- Sanity check:
203                 | ImportBySystem <- from,       --   system-importing...
204                   modulePackageId (mi_module iface) == thisPackage dflags,
205                                                 --   a home-package module...
206                   Nothing <- mb_dep             --   that we know nothing about
207                 -> returnM (Failed (badDepMsg mod))
208
209                 | otherwise ->
210
211         let 
212             loc_doc = text file_path
213         in 
214         initIfaceLcl mod loc_doc $ do
215
216         --      Load the new ModIface into the External Package State
217         -- Even home-package interfaces loaded by loadInterface 
218         --      (which only happens in OneShot mode; in Batch/Interactive 
219         --      mode, home-package modules are loaded one by one into the HPT)
220         -- are put in the EPS.
221         --
222         -- The main thing is to add the ModIface to the PIT, but
223         -- we also take the
224         --      IfaceDecls, IfaceInst, IfaceRules
225         -- out of the ModIface and put them into the big EPS pools
226
227         -- NB: *first* we do loadDecl, so that the provenance of all the locally-defined
228         ---    names is done correctly (notably, whether this is an .hi file or .hi-boot file).
229         --     If we do loadExport first the wrong info gets into the cache (unless we
230         --      explicitly tag each export which seems a bit of a bore)
231
232         ; ignore_prags <- doptM Opt_IgnoreInterfacePragmas
233         ; new_eps_decls <- loadDecls ignore_prags (mi_decls iface)
234         ; new_eps_insts <- mapM tcIfaceInst (mi_insts iface)
235         ; new_eps_rules <- if ignore_prags 
236                            then return []
237                            else mapM tcIfaceRule (mi_rules iface)
238
239         ; let { final_iface = iface {   mi_decls = panic "No mi_decls in PIT",
240                                         mi_insts = panic "No mi_insts in PIT",
241                                         mi_rules = panic "No mi_rules in PIT" } }
242
243         ; updateEps_  $ \ eps -> 
244             eps { eps_PIT       = extendModuleEnv (eps_PIT eps) mod final_iface,
245                   eps_PTE       = addDeclsToPTE   (eps_PTE eps) new_eps_decls,
246                   eps_rule_base = extendRuleBaseList (eps_rule_base eps) new_eps_rules,
247                   eps_inst_env  = extendInstEnvList  (eps_inst_env eps)  new_eps_insts,
248                   eps_stats     = addEpsInStats (eps_stats eps) (length new_eps_decls)
249                                                 (length new_eps_insts) (length new_eps_rules) }
250
251         ; return (Succeeded final_iface)
252     }}}}
253
254 badDepMsg mod 
255   = hang (ptext SLIT("Interface file inconsistency:"))
256        2 (sep [ptext SLIT("home-package module") <+> quotes (ppr mod) <+> ptext SLIT("is mentioned,"), 
257                ptext SLIT("but does not appear in the dependencies of the interface")])
258
259 -----------------------------------------------------
260 --      Loading type/class/value decls
261 -- We pass the full Module name here, replete with
262 -- its package info, so that we can build a Name for
263 -- each binder with the right package info in it
264 -- All subsequent lookups, including crucially lookups during typechecking
265 -- the declaration itself, will find the fully-glorious Name
266 -----------------------------------------------------
267
268 addDeclsToPTE :: PackageTypeEnv -> [(Name,TyThing)] -> PackageTypeEnv
269 addDeclsToPTE pte things = extendNameEnvList pte things
270
271 loadDecls :: Bool
272           -> [(Version, IfaceDecl)]
273           -> IfL [(Name,TyThing)]
274 loadDecls ignore_prags ver_decls
275    = do { mod <- getIfModule
276         ; thingss <- mapM (loadDecl ignore_prags mod) ver_decls
277         ; return (concat thingss)
278         }
279
280 loadDecl :: Bool                        -- Don't load pragmas into the decl pool
281          -> Module
282           -> (Version, IfaceDecl)
283           -> IfL [(Name,TyThing)]       -- The list can be poked eagerly, but the
284                                         -- TyThings are forkM'd thunks
285 loadDecl ignore_prags mod (_version, decl)
286   = do  {       -- Populate the name cache with final versions of all 
287                 -- the names associated with the decl
288           main_name      <- mk_new_bndr mod Nothing (ifName decl)
289         ; implicit_names <- mapM (mk_new_bndr mod (Just main_name)) (ifaceDeclSubBndrs decl)
290
291         -- Typecheck the thing, lazily
292         -- NB. firstly, the laziness is there in case we never need the
293         -- declaration (in one-shot mode), and secondly it is there so that 
294         -- we don't look up the occurrence of a name before calling mk_new_bndr
295         -- on the binder.  This is important because we must get the right name
296         -- which includes its nameParent.
297         ; thing <- forkM doc (bumpDeclStats main_name >> tcIfaceDecl stripped_decl)
298         ; let mini_env = mkOccEnv [(getOccName t, t) | t <- implicitTyThings thing]
299               lookup n = case lookupOccEnv mini_env (getOccName n) of
300                            Just thing -> thing
301                            Nothing    -> pprPanic "loadDecl" (ppr main_name <+> ppr n)
302
303         ; returnM ((main_name, thing) : [(n, lookup n) | n <- implicit_names]) }
304                 -- We build a list from the *known* names, with (lookup n) thunks
305                 -- as the TyThings.  That way we can extend the PTE without poking the
306                 -- thunks
307   where
308     stripped_decl | ignore_prags = discardDeclPrags decl
309                   | otherwise    = decl
310
311         -- mk_new_bndr allocates in the name cache the final canonical
312         -- name for the thing, with the correct 
313         --      * parent
314         --      * location
315         -- imported name, to fix the module correctly in the cache
316     mk_new_bndr mod mb_parent occ 
317         = newGlobalBinder mod occ mb_parent 
318                           (importedSrcLoc (showSDoc (ppr (moduleName mod))))
319                         -- ToDo: qualify with the package name if necessary
320
321     doc = ptext SLIT("Declaration for") <+> ppr (ifName decl)
322
323 discardDeclPrags :: IfaceDecl -> IfaceDecl
324 discardDeclPrags decl@(IfaceId {ifIdInfo = HasInfo _}) = decl { ifIdInfo = NoInfo }
325 discardDeclPrags decl                                  = decl
326
327 bumpDeclStats :: Name -> IfL ()         -- Record that one more declaration has actually been used
328 bumpDeclStats name
329   = do  { traceIf (text "Loading decl for" <+> ppr name)
330         ; updateEps_ (\eps -> let stats = eps_stats eps
331                               in eps { eps_stats = stats { n_decls_out = n_decls_out stats + 1 } })
332         }
333
334 -----------------
335 ifaceDeclSubBndrs :: IfaceDecl -> [OccName]
336 --  *Excludes* the 'main' name, but *includes* the implicitly-bound names
337 -- Deeply revolting, because it has to predict what gets bound,
338 -- especially the question of whether there's a wrapper for a datacon
339
340 ifaceDeclSubBndrs (IfaceClass {ifCtxt = sc_ctxt, ifName = cls_occ, ifSigs = sigs })
341   = [tc_occ, dc_occ, dcww_occ] ++
342     [op | IfaceClassOp op _ _ <- sigs] ++
343     [mkSuperDictSelOcc n cls_occ | n <- [1..n_ctxt]] 
344   where
345     n_ctxt = length sc_ctxt
346     n_sigs = length sigs
347     tc_occ  = mkClassTyConOcc cls_occ
348     dc_occ  = mkClassDataConOcc cls_occ 
349     dcww_occ | is_newtype = mkDataConWrapperOcc dc_occ  -- Newtypes have wrapper but no worker
350              | otherwise  = mkDataConWorkerOcc dc_occ   -- Otherwise worker but no wrapper
351     is_newtype = n_sigs + n_ctxt == 1                   -- Sigh 
352
353 ifaceDeclSubBndrs (IfaceData {ifCons = IfAbstractTyCon}) 
354   = []
355 -- Newtype
356 ifaceDeclSubBndrs (IfaceData {ifCons = IfNewTyCon (IfVanillaCon { ifConOcc = con_occ, 
357                                                                   ifConFields = fields})}) 
358   = fields ++ [con_occ, mkDataConWrapperOcc con_occ]    
359         -- Wrapper, no worker; see MkId.mkDataConIds
360
361 ifaceDeclSubBndrs (IfaceData {ifCons = IfDataTyCon cons})
362   = nub (concatMap fld_occs cons)       -- Eliminate duplicate fields
363     ++ concatMap dc_occs cons
364   where
365     fld_occs (IfVanillaCon { ifConFields = fields }) = fields
366     fld_occs (IfGadtCon {})                          = []
367     dc_occs con_decl
368         | has_wrapper = [con_occ, work_occ, wrap_occ]
369         | otherwise   = [con_occ, work_occ]
370         where
371           con_occ = ifConOcc con_decl
372           strs    = ifConStricts con_decl
373           wrap_occ = mkDataConWrapperOcc con_occ
374           work_occ = mkDataConWorkerOcc con_occ
375           has_wrapper = any isMarkedStrict strs -- See MkId.mkDataConIds (sigh)
376                 -- ToDo: may miss strictness in existential dicts
377
378 ifaceDeclSubBndrs _other                      = []
379
380 \end{code}
381
382
383 %*********************************************************
384 %*                                                      *
385 \subsection{Reading an interface file}
386 %*                                                      *
387 %*********************************************************
388
389 \begin{code}
390 findAndReadIface :: SDoc -> Module
391                  -> IsBootInterface     -- True  <=> Look for a .hi-boot file
392                                         -- False <=> Look for .hi file
393                  -> TcRnIf gbl lcl (MaybeErr Message (ModIface, FilePath))
394         -- Nothing <=> file not found, or unreadable, or illegible
395         -- Just x  <=> successfully found and parsed 
396
397         -- It *doesn't* add an error to the monad, because 
398         -- sometimes it's ok to fail... see notes with loadInterface
399
400 findAndReadIface doc_str mod hi_boot_file
401   = do  { traceIf (sep [hsep [ptext SLIT("Reading"), 
402                               if hi_boot_file 
403                                 then ptext SLIT("[boot]") 
404                                 else empty,
405                               ptext SLIT("interface for"), 
406                               ppr mod <> semi],
407                         nest 4 (ptext SLIT("reason:") <+> doc_str)])
408
409         -- Check for GHC.Prim, and return its static interface
410         ; dflags <- getDOpts
411         ; if mod == gHC_PRIM
412           then returnM (Succeeded (ghcPrimIface, 
413                                    "<built in interface for GHC.Prim>"))
414           else do
415
416         -- Look for the file
417         ; hsc_env <- getTopEnv
418         ; mb_found <- ioToIOEnv (findHiFile hsc_env mod hi_boot_file)
419         ; case mb_found of {
420               Failed err -> do
421                 { traceIf (ptext SLIT("...not found"))
422                 ; dflags <- getDOpts
423                 ; returnM (Failed (cantFindError dflags (moduleName mod) err)) } ;
424
425               Succeeded file_path -> do 
426
427         -- Found file, so read it
428         { traceIf (ptext SLIT("readIFace") <+> text file_path)
429         ; read_result <- readIface mod file_path hi_boot_file
430         ; case read_result of
431             Failed err -> returnM (Failed (badIfaceFile file_path err))
432             Succeeded iface 
433                 | mi_module iface /= mod ->
434                   return (Failed (wrongIfaceModErr iface mod file_path))
435                 | otherwise ->
436                   returnM (Succeeded (iface, file_path))
437                         -- Don't forget to fill in the package name...
438         }}}
439
440 findHiFile :: HscEnv -> Module -> IsBootInterface
441            -> IO (MaybeErr FindResult FilePath)
442 findHiFile hsc_env mod hi_boot_file
443   = do
444       maybe_found <- findExactModule hsc_env mod
445       case maybe_found of
446         Found loc mod -> return (Succeeded path)
447                 where
448                    path = addBootSuffix_maybe hi_boot_file (ml_hi_file loc)
449         err -> return (Failed err)
450 \end{code}
451
452 @readIface@ tries just the one file.
453
454 \begin{code}
455 readIface :: Module -> FilePath -> IsBootInterface 
456           -> TcRnIf gbl lcl (MaybeErr Message ModIface)
457         -- Failed err    <=> file not found, or unreadable, or illegible
458         -- Succeeded iface <=> successfully found and parsed 
459
460 readIface wanted_mod file_path is_hi_boot_file
461   = do  { dflags <- getDOpts
462         ; ioToIOEnv $ do
463         { res <- tryMost (readBinIface file_path)
464         ; case res of
465             Right iface 
466                 | wanted_mod == actual_mod -> return (Succeeded iface)
467                 | otherwise                -> return (Failed err)
468                 where
469                   actual_mod = mi_module iface
470                   err = hiModuleNameMismatchWarn wanted_mod actual_mod
471
472             Left exn    -> return (Failed (text (showException exn)))
473     }}
474 \end{code}
475
476
477 %*********************************************************
478 %*                                                       *
479         Wired-in interface for GHC.Prim
480 %*                                                       *
481 %*********************************************************
482
483 \begin{code}
484 initExternalPackageState :: ExternalPackageState
485 initExternalPackageState
486   = EPS { 
487       eps_is_boot    = emptyUFM,
488       eps_PIT        = emptyPackageIfaceTable,
489       eps_PTE        = emptyTypeEnv,
490       eps_inst_env   = emptyInstEnv,
491       eps_rule_base  = mkRuleBase builtinRules,
492         -- Initialise the EPS rule pool with the built-in rules
493       eps_stats = EpsStats { n_ifaces_in = 0, n_decls_in = 0, n_decls_out = 0
494                            , n_insts_in = 0, n_insts_out = 0
495                            , n_rules_in = length builtinRules, n_rules_out = 0 }
496     }
497 \end{code}
498
499
500 %*********************************************************
501 %*                                                       *
502         Wired-in interface for GHC.Prim
503 %*                                                       *
504 %*********************************************************
505
506 \begin{code}
507 ghcPrimIface :: ModIface
508 ghcPrimIface
509   = (emptyModIface gHC_PRIM) {
510         mi_exports  = [(gHC_PRIM, ghcPrimExports)],
511         mi_decls    = [],
512         mi_fixities = fixities,
513         mi_fix_fn  = mkIfaceFixCache fixities
514     }           
515   where
516     fixities = [(getOccName seqId, Fixity 0 InfixR)]
517                         -- seq is infixr 0
518 \end{code}
519
520 %*********************************************************
521 %*                                                      *
522 \subsection{Statistics}
523 %*                                                      *
524 %*********************************************************
525
526 \begin{code}
527 ifaceStats :: ExternalPackageState -> SDoc
528 ifaceStats eps 
529   = hcat [text "Renamer stats: ", msg]
530   where
531     stats = eps_stats eps
532     msg = vcat 
533         [int (n_ifaces_in stats) <+> text "interfaces read",
534          hsep [ int (n_decls_out stats), text "type/class/variable imported, out of", 
535                 int (n_decls_in stats), text "read"],
536          hsep [ int (n_insts_out stats), text "instance decls imported, out of",  
537                 int (n_insts_in stats), text "read"],
538          hsep [ int (n_rules_out stats), text "rule decls imported, out of",  
539                 int (n_rules_in stats), text "read"]
540         ]
541 \end{code}    
542
543
544 %*********************************************************
545 %*                                                       *
546 \subsection{Errors}
547 %*                                                       *
548 %*********************************************************
549
550 \begin{code}
551 badIfaceFile file err
552   = vcat [ptext SLIT("Bad interface file:") <+> text file, 
553           nest 4 err]
554
555 hiModuleNameMismatchWarn :: Module -> Module -> Message
556 hiModuleNameMismatchWarn requested_mod read_mod = 
557   withPprStyle defaultUserStyle $
558     -- we want the Modules below to be qualified with package names,
559     -- so reset the PrintUnqualified setting.
560     hsep [ ptext SLIT("Something is amiss; requested module ")
561          , ppr requested_mod
562          , ptext SLIT("differs from name found in the interface file")
563          , ppr read_mod
564          ]
565
566 wrongIfaceModErr iface mod_name file_path 
567   = sep [ptext SLIT("Interface file") <+> iface_file,
568          ptext SLIT("contains module") <+> quotes (ppr (mi_module iface)) <> comma,
569          ptext SLIT("but we were expecting module") <+> quotes (ppr mod_name),
570          sep [ptext SLIT("Probable cause: the source code which generated"),
571              nest 2 iface_file,
572              ptext SLIT("has an incompatible module name")
573             ]
574         ]
575   where iface_file = doubleQuotes (text file_path)
576 \end{code}