[project @ 2000-10-25 15:57:33 by simonpj]
[ghc-hetmet.git] / ghc / compiler / rename / RnHiFiles.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 RnHiFiles (
8         findAndReadIface, loadInterface, loadHomeInterface, 
9         tryLoadInterface, loadOrphanModules,
10         loadExports, loadFixDecls, loadDeprecs,
11
12         lookupFixityRn, 
13
14         getTyClDeclBinders, 
15         removeContext           -- removeContext probably belongs somewhere else
16    ) where
17
18 #include "HsVersions.h"
19
20 import CmdLineOpts      ( opt_IgnoreIfacePragmas )
21 import HscTypes
22 import HsSyn            ( HsDecl(..), TyClDecl(..), InstDecl(..),
23                           HsType(..), ConDecl(..), 
24                           FixitySig(..), RuleDecl(..),
25                           tyClDeclNames
26                         )
27 import RdrHsSyn         ( RdrNameTyClDecl, RdrNameInstDecl, RdrNameRuleDecl,
28                           extractHsTyRdrNames 
29                         )
30 import BasicTypes       ( Version, defaultFixity )
31 import RnEnv
32 import RnMonad
33 import ParseIface       ( parseIface, IfaceStuff(..) )
34
35 import Name             ( Name {-instance NamedThing-}, nameOccName,
36                           nameModule, isLocallyDefined, 
37                           NamedThing(..),
38                           mkNameEnv, extendNameEnv
39                          )
40 import Module           ( Module,
41                           moduleName, isModuleInThisPackage,
42                           ModuleName, WhereFrom(..),
43                           extendModuleEnv, lookupModuleEnvByName,
44                         )
45 import RdrName          ( RdrName, rdrNameOcc )
46 import NameSet
47 import SrcLoc           ( mkSrcLoc, SrcLoc )
48 import Maybes           ( maybeToBool, orElse )
49 import StringBuffer     ( hGetStringBuffer )
50 import FastString       ( mkFastString )
51 import ErrUtils         ( Message )
52 import Lex
53 import FiniteMap
54 import Outputable
55 import Bag
56 \end{code}
57
58
59 %*********************************************************
60 %*                                                      *
61 \subsection{Loading a new interface file}
62 %*                                                      *
63 %*********************************************************
64
65 \begin{code}
66 loadHomeInterface :: SDoc -> Name -> RnM d Ifaces
67 loadHomeInterface doc_str name
68   = loadInterface doc_str (moduleName (nameModule name)) ImportBySystem
69
70 loadOrphanModules :: [ModuleName] -> RnM d ()
71 loadOrphanModules mods
72   | null mods = returnRn ()
73   | otherwise = traceRn (text "Loading orphan modules:" <+> 
74                          fsep (map ppr mods))                   `thenRn_` 
75                 mapRn_ load mods                                `thenRn_`
76                 returnRn ()
77   where
78     load mod   = loadInterface (mk_doc mod) mod ImportBySystem
79     mk_doc mod = ppr mod <+> ptext SLIT("is a orphan-instance module")
80
81 loadInterface :: SDoc -> ModuleName -> WhereFrom -> RnM d Ifaces
82 loadInterface doc mod from 
83   = tryLoadInterface doc mod from       `thenRn` \ (ifaces, maybe_err) ->
84     case maybe_err of
85         Nothing  -> returnRn ifaces
86         Just err -> failWithRn ifaces err
87
88 tryLoadInterface :: SDoc -> ModuleName -> WhereFrom -> RnM d (Ifaces, Maybe Message)
89         -- Returns (Just err) if an error happened
90         -- Guarantees to return with iImpModInfo m --> (..., True)
91         -- (If the load fails, we plug in a vanilla placeholder)
92 tryLoadInterface doc_str mod_name from
93  = getHomeIfaceTableRn          `thenRn` \ hit ->
94    getIfacesRn                  `thenRn` \ ifaces ->
95         
96         -- Check whether we have it already in the home package
97    case lookupModuleEnvByName hit mod_name of {
98         Just _  -> returnRn (ifaces, Nothing) ; -- In the home package
99         Nothing -> 
100
101    let
102         mod_map  = iImpModInfo ifaces
103         mod_info = lookupFM mod_map mod_name
104
105         hi_boot_file 
106           = case (from, mod_info) of
107                 (ImportByUser,       _)                -> False         -- Not hi-boot
108                 (ImportByUserSource, _)                -> True          -- hi-boot
109                 (ImportBySystem, Just (_, is_boot, _)) -> is_boot       -- 
110                 (ImportBySystem, Nothing)              -> False
111                         -- We're importing a module we know absolutely
112                         -- nothing about, so we assume it's from
113                         -- another package, where we aren't doing 
114                         -- dependency tracking. So it won't be a hi-boot file.
115
116         redundant_source_import 
117           = case (from, mod_info) of 
118                 (ImportByUserSource, Just (_,False,_)) -> True
119                 other                                  -> False
120    in
121         -- CHECK WHETHER WE HAVE IT ALREADY
122    case mod_info of {
123         Just (_, _, True)
124                 ->      -- We're read it already so don't re-read it
125                     returnRn (ifaces, Nothing) ;
126
127         _ ->
128
129         -- Issue a warning for a redundant {- SOURCE -} import
130         -- NB that we arrange to read all the ordinary imports before 
131         -- any of the {- SOURCE -} imports
132    warnCheckRn  (not redundant_source_import)
133                 (warnRedundantSourceImport mod_name)    `thenRn_`
134
135         -- READ THE MODULE IN
136    findAndReadIface doc_str mod_name hi_boot_file   `thenRn` \ read_result ->
137    case read_result of {
138         Left err ->     -- Not found, so add an empty export env to the Ifaces map
139                         -- so that we don't look again
140            let
141                 new_mod_map = addToFM mod_map mod_name (False, False, True)
142                 new_ifaces  = ifaces { iImpModInfo = new_mod_map }
143            in
144            setIfacesRn new_ifaces               `thenRn_`
145            returnRn (new_ifaces, Just err) ;
146
147         -- Found and parsed!
148         Right (mod, iface) ->
149
150         -- LOAD IT INTO Ifaces
151
152         -- NB: *first* we do loadDecl, so that the provenance of all the locally-defined
153         ---    names is done correctly (notably, whether this is an .hi file or .hi-boot file).
154         --     If we do loadExport first the wrong info gets into the cache (unless we
155         --      explicitly tag each export which seems a bit of a bore)
156
157
158         -- Sanity check.  If we're system-importing a module we know nothing at all
159         -- about, it should be from a different package to this one
160     WARN( not (maybeToBool mod_info) && 
161           case from of { ImportBySystem -> True; other -> False } &&
162           isModuleInThisPackage mod,
163           ppr mod )
164
165     loadDecls mod               (iDecls ifaces)   (pi_decls iface)      `thenRn` \ (decls_vers, new_decls) ->
166     loadRules mod               (iRules ifaces)   (pi_rules iface)      `thenRn` \ (rule_vers, new_rules) ->
167     foldlRn (loadInstDecl mod)  (iInsts ifaces)   (pi_insts iface)      `thenRn` \ new_insts ->
168     loadExports                                   (pi_exports iface)    `thenRn` \ (export_vers, avails) ->
169     loadFixDecls mod                              (pi_fixity iface)     `thenRn` \ fix_env ->
170     loadDeprecs mod                               (pi_deprecs iface)    `thenRn` \ deprec_env ->
171     let
172         version = VersionInfo { vers_module  = pi_vers iface, 
173                                 vers_exports = export_vers,
174                                 vers_rules = rule_vers,
175                                 vers_decls = decls_vers }
176
177         -- For an explicit user import, add to mod_map info about
178         -- the things the imported module depends on, extracted
179         -- from its usage info.
180         mod_map1 = case from of
181                         ImportByUser -> addModDeps mod (pi_usages iface) mod_map
182                         other        -> mod_map
183         mod_map2 = addToFM mod_map1 mod_name (has_orphans, hi_boot_file, True)
184
185         -- Now add info about this module to the PIT
186         has_orphans = pi_orphan iface
187         new_pit   = extendModuleEnv (iPIT ifaces) mod mod_iface
188         mod_iface = ModIface { mi_module = mod, mi_version = version,
189                                mi_exports = avails, mi_orphan = has_orphans,
190                                mi_fixities = fix_env, mi_deprecs = deprec_env,
191                                mi_usages  = [], -- Will be filled in later
192                                mi_decls   = panic "No mi_decls in PIT",
193                                mi_globals = panic "No mi_globals in PIT"
194                     }
195
196         new_ifaces = ifaces { iPIT        = new_pit,
197                               iDecls      = new_decls,
198                               iInsts      = new_insts,
199                               iRules      = new_rules,
200                               iImpModInfo = mod_map2  }
201     in
202     setIfacesRn new_ifaces              `thenRn_`
203     returnRn (new_ifaces, Nothing)
204     }}}
205
206 -----------------------------------------------------
207 --      Adding module dependencies from the 
208 --      import decls in the interface file
209 -----------------------------------------------------
210
211 addModDeps :: Module -> [ImportVersion a] 
212            -> ImportedModuleInfo -> ImportedModuleInfo
213 -- (addModDeps M ivs deps)
214 -- We are importing module M, and M.hi contains 'import' decls given by ivs
215 addModDeps mod new_deps mod_deps
216   = foldr add mod_deps filtered_new_deps
217   where
218         -- Don't record dependencies when importing a module from another package
219         -- Except for its descendents which contain orphans,
220         -- and in that case, forget about the boot indicator
221     filtered_new_deps :: [(ModuleName, (WhetherHasOrphans, IsBootInterface, IsLoaded))]
222     filtered_new_deps
223         | isModuleInThisPackage mod 
224                             = [ (imp_mod, (has_orphans, is_boot, False))
225                               | (imp_mod, has_orphans, is_boot, _) <- new_deps 
226                               ]                       
227         | otherwise         = [ (imp_mod, (True, False, False))
228                               | (imp_mod, has_orphans, _, _) <- new_deps, 
229                                 has_orphans
230                               ]
231     add (imp_mod, dep) deps = addToFM_C combine deps imp_mod dep
232
233     combine old@(_, old_is_boot, old_is_loaded) new
234         | old_is_loaded || not old_is_boot = old        -- Keep the old info if it's already loaded
235                                                         -- or if it's a non-boot pending load
236         | otherwise                         = new       -- Otherwise pick new info
237
238
239 -----------------------------------------------------
240 --      Loading the export list
241 -----------------------------------------------------
242
243 loadExports :: (Version, [ExportItem]) -> RnM d (Version, [(ModuleName,Avails)])
244 loadExports (vers, items)
245   = getModuleRn                                 `thenRn` \ this_mod ->
246     mapRn (loadExport this_mod) items           `thenRn` \ avails_s ->
247     returnRn (vers, avails_s)
248
249
250 loadExport :: Module -> ExportItem -> RnM d (ModuleName, Avails)
251 loadExport this_mod (mod, entities)
252   | mod == moduleName this_mod = returnRn (mod, [])
253         -- If the module exports anything defined in this module, just ignore it.
254         -- Reason: otherwise it looks as if there are two local definition sites
255         -- for the thing, and an error gets reported.  Easiest thing is just to
256         -- filter them out up front. This situation only arises if a module
257         -- imports itself, or another module that imported it.  (Necessarily,
258         -- this invoves a loop.)  Consequence: if you say
259         --      module A where
260         --         import B( AType )
261         --         type AType = ...
262         --
263         --      module B( AType ) where
264         --         import {-# SOURCE #-} A( AType )
265         --
266         -- then you'll get a 'B does not export AType' message.  A bit bogus
267         -- but it's a bogus thing to do!
268
269   | otherwise
270   = mapRn (load_entity mod) entities    `thenRn` \ avails ->
271     returnRn (mod, avails)
272   where
273     new_name mod occ = newGlobalName mod occ
274
275     load_entity mod (Avail occ)
276       = new_name mod occ        `thenRn` \ name ->
277         returnRn (Avail name)
278     load_entity mod (AvailTC occ occs)
279       = new_name mod occ              `thenRn` \ name ->
280         mapRn (new_name mod) occs     `thenRn` \ names ->
281         returnRn (AvailTC name names)
282
283
284 -----------------------------------------------------
285 --      Loading type/class/value decls
286 -----------------------------------------------------
287
288 loadDecls :: Module 
289           -> DeclsMap
290           -> [(Version, RdrNameTyClDecl)]
291           -> RnM d (NameEnv Version, DeclsMap)
292 loadDecls mod decls_map decls
293   = foldlRn (loadDecl mod) (emptyNameEnv, decls_map) decls
294
295 loadDecl :: Module 
296          -> (NameEnv Version, DeclsMap)
297          -> (Version, RdrNameTyClDecl)
298          -> RnM d (NameEnv Version, DeclsMap)
299 loadDecl mod (version_map, decls_map) (version, decl)
300   = getIfaceDeclBinders new_name decl   `thenRn` \ full_avail ->
301     let
302         main_name     = availName full_avail
303         new_decls_map = extendNameEnvList decls_map stuff
304         stuff         = [ (name, (full_avail, name==main_name, (mod, decl))) 
305                         | name <- availNames full_avail]
306
307         new_version_map = extendNameEnv version_map main_name version
308     in
309     returnRn (new_version_map, new_decls_map)
310   where
311         -- newTopBinder puts into the cache the binder with the
312         -- module information set correctly.  When the decl is later renamed,
313         -- the binding site will thereby get the correct module.
314         -- There maybe occurrences that don't have the correct Module, but
315         -- by the typechecker will propagate the binding definition to all 
316         -- the occurrences, so that doesn't matter
317     new_name rdr_name loc = newTopBinder mod rdr_name loc
318
319
320 -----------------------------------------------------
321 --      Loading fixity decls
322 -----------------------------------------------------
323
324 loadFixDecls mod decls
325   = mapRn (loadFixDecl mod_name) decls  `thenRn` \ to_add ->
326     returnRn (mkNameEnv to_add)
327   where
328     mod_name = moduleName mod
329
330 loadFixDecl mod_name sig@(FixitySig rdr_name fixity loc)
331   = newGlobalName mod_name (rdrNameOcc rdr_name)        `thenRn` \ name ->
332     returnRn (name, fixity)
333
334
335 -----------------------------------------------------
336 --      Loading instance decls
337 -----------------------------------------------------
338
339 loadInstDecl :: Module
340              -> IfaceInsts
341              -> RdrNameInstDecl
342              -> RnM d IfaceInsts
343 loadInstDecl mod insts decl@(InstDecl inst_ty binds uprags dfun_name src_loc)
344   = 
345         -- Find out what type constructors and classes are "gates" for the
346         -- instance declaration.  If all these "gates" are slurped in then
347         -- we should slurp the instance decl too.
348         -- 
349         -- We *don't* want to count names in the context part as gates, though.
350         -- For example:
351         --              instance Foo a => Baz (T a) where ...
352         --
353         -- Here the gates are Baz and T, but *not* Foo.
354     let 
355         munged_inst_ty = removeContext inst_ty
356         free_names     = extractHsTyRdrNames munged_inst_ty
357     in
358     setModuleRn mod $
359     mapRn lookupOrigName free_names     `thenRn` \ gate_names ->
360     returnRn ((mkNameSet gate_names, (mod, InstD decl)) `consBag` insts)
361
362
363 -- In interface files, the instance decls now look like
364 --      forall a. Foo a -> Baz (T a)
365 -- so we have to strip off function argument types as well
366 -- as the bit before the '=>' (which is always empty in interface files)
367 removeContext (HsForAllTy tvs cxt ty) = HsForAllTy tvs [] (removeFuns ty)
368 removeContext ty                      = removeFuns ty
369
370 removeFuns (HsFunTy _ ty) = removeFuns ty
371 removeFuns ty               = ty
372
373
374 -----------------------------------------------------
375 --      Loading Rules
376 -----------------------------------------------------
377
378 loadRules :: Module -> IfaceRules 
379           -> (Version, [RdrNameRuleDecl])
380           -> RnM d (Version, IfaceRules)
381 loadRules mod rule_bag (version, rules)
382   | null rules || opt_IgnoreIfacePragmas 
383   = returnRn (version, rule_bag)
384   | otherwise
385   = setModuleRn mod                     $
386     mapRn (loadRule mod) rules          `thenRn` \ new_rules ->
387     returnRn (version, rule_bag `unionBags` listToBag new_rules)
388
389 loadRule :: Module -> RdrNameRuleDecl -> RnM d GatedDecl
390 -- "Gate" the rule simply by whether the rule variable is
391 -- needed.  We can refine this later.
392 loadRule mod decl@(IfaceRule _ _ var _ _ src_loc)
393   = lookupOrigName var          `thenRn` \ var_name ->
394     returnRn (unitNameSet var_name, (mod, RuleD decl))
395
396
397 -----------------------------------------------------
398 --      Loading Deprecations
399 -----------------------------------------------------
400
401 loadDeprecs :: Module -> IfaceDeprecs -> RnM d Deprecations
402 loadDeprecs m Nothing                                  = returnRn NoDeprecs
403 loadDeprecs m (Just (Left txt))  = returnRn (DeprecAll txt)
404 loadDeprecs m (Just (Right prs)) = setModuleRn m                                $
405                                    foldlRn loadDeprec emptyNameEnv prs  `thenRn` \ env ->
406                                    returnRn (DeprecSome env)
407 loadDeprec deprec_env (n, txt)
408   = lookupOrigName n            `thenRn` \ name ->
409     traceRn (text "Loaded deprecation(s) for" <+> ppr name <> colon <+> ppr txt) `thenRn_`
410     returnRn (extendNameEnv deprec_env name txt)
411 \end{code}
412
413
414 %*********************************************************
415 %*                                                      *
416 \subsection{Getting binders out of a declaration}
417 %*                                                      *
418 %*********************************************************
419
420 @getDeclBinders@ returns the names for a @RdrNameHsDecl@.
421 It's used for both source code (from @availsFromDecl@) and interface files
422 (from @loadDecl@).
423
424 It doesn't deal with source-code specific things: @ValD@, @DefD@.  They
425 are handled by the sourc-code specific stuff in @RnNames@.
426
427 \begin{code}
428 getIfaceDeclBinders, getTyClDeclBinders
429         :: (RdrName -> SrcLoc -> RnM d Name)    -- New-name function
430         -> RdrNameTyClDecl
431         -> RnM d AvailInfo
432
433 getIfaceDeclBinders new_name tycl_decl
434   = getTyClDeclBinders    new_name tycl_decl    `thenRn` \ avail ->
435     getSysTyClDeclBinders new_name tycl_decl    `thenRn` \ extras ->
436     returnRn (addSysAvails avail extras)
437                 -- Add the sys-binders to avail.  When we import the decl,
438                 -- it's full_avail that will get added to the 'already-slurped' set (iSlurp)
439                 -- If we miss out sys-binders, we'll read the decl multiple times!
440
441 getTyClDeclBinders new_name (IfaceSig var ty prags src_loc)
442   = new_name var src_loc                        `thenRn` \ var_name ->
443     returnRn (Avail var_name)
444
445 getTyClDeclBinders new_name tycl_decl
446   = mapRn do_one (tyClDeclNames tycl_decl)      `thenRn` \ (main_name:sub_names) ->
447     returnRn (AvailTC main_name (main_name : sub_names))
448   where
449     do_one (name,loc) = new_name name loc
450 \end{code}
451
452 @getDeclSysBinders@ gets the implicit binders introduced by a decl.
453 A the moment that's just the tycon and datacon that come with a class decl.
454 They aren't returned by @getDeclBinders@ because they aren't in scope;
455 but they {\em should} be put into the @DeclsMap@ of this module.
456
457 Note that this excludes the default-method names of a class decl,
458 and the dict fun of an instance decl, because both of these have 
459 bindings of their own elsewhere.
460
461 \begin{code}
462 getSysTyClDeclBinders new_name (ClassDecl _ cname _ _ sigs _ names src_loc)
463   = sequenceRn [new_name n src_loc | n <- names]
464
465 getSysTyClDeclBinders new_name (TyData _ _ _ _ cons _ _ _ _ _)
466   = sequenceRn [new_name wkr_name src_loc | ConDecl _ wkr_name _ _ _ src_loc <- cons]
467
468 getSysTyClDeclBinders new_name other_decl
469   = returnRn []
470 \end{code}
471
472
473
474 %*********************************************************
475 %*                                                      *
476 \subsection{Reading an interface file}
477 %*                                                      *
478 %*********************************************************
479
480 \begin{code}
481 findAndReadIface :: SDoc -> ModuleName 
482                  -> IsBootInterface     -- True  <=> Look for a .hi-boot file
483                                         -- False <=> Look for .hi file
484                  -> RnM d (Either Message (Module, ParsedIface))
485         -- Nothing <=> file not found, or unreadable, or illegible
486         -- Just x  <=> successfully found and parsed 
487
488 findAndReadIface doc_str mod_name hi_boot_file
489   = traceRn trace_msg                   `thenRn_`
490
491     getFinderRn                         `thenRn` \ finder ->
492     ioToRnM (finder mod_name)           `thenRn` \ maybe_found ->
493
494     case maybe_found of
495       Right (Just (mod,locn))
496         | hi_boot_file -> readIface mod (hi_file locn ++ "-hi-boot")
497         | otherwise    -> readIface mod (hi_file locn)
498         
499         -- Can't find it
500       other   -> traceRn (ptext SLIT("...not found"))   `thenRn_`
501                  returnRn (Left (noIfaceErr mod_name hi_boot_file))
502
503   where
504     trace_msg = sep [hsep [ptext SLIT("Reading"), 
505                            if hi_boot_file then ptext SLIT("[boot]") else empty,
506                            ptext SLIT("interface for"), 
507                            ppr mod_name <> semi],
508                      nest 4 (ptext SLIT("reason:") <+> doc_str)]
509 \end{code}
510
511 @readIface@ tries just the one file.
512
513 \begin{code}
514 readIface :: Module -> String -> RnM d (Either Message (Module, ParsedIface))
515         -- Nothing <=> file not found, or unreadable, or illegible
516         -- Just x  <=> successfully found and parsed 
517 readIface wanted_mod file_path
518   = traceRn (ptext SLIT("...reading from") <+> text file_path)  `thenRn_`
519     ioToRnM (hGetStringBuffer False file_path)                   `thenRn` \ read_result ->
520     case read_result of
521         Right contents    -> 
522              case parseIface contents
523                         PState{ bol = 0#, atbol = 1#,
524                                 context = [],
525                                 glasgow_exts = 1#,
526                                 loc = mkSrcLoc (mkFastString file_path) 1 } of
527                   POk _  (PIface iface) ->
528                       warnCheckRn (wanted_mod == read_mod)
529                                   (hiModuleNameMismatchWarn wanted_mod read_mod) `thenRn_`
530                       returnRn (Right (wanted_mod, iface))
531                     where
532                       read_mod = pi_mod iface
533
534                   PFailed err   -> bale_out err
535                   parse_result  -> bale_out empty
536                         -- This last case can happen if the interface file is (say) empty
537                         -- in which case the parser thinks it looks like an IdInfo or
538                         -- something like that.  Just an artefact of the fact that the
539                         -- parser is used for several purposes at once.
540
541         Left io_err -> bale_out (text (show io_err))
542   where
543     bale_out err = returnRn (Left (badIfaceFile file_path err))
544 \end{code}
545
546
547 %*********************************************************
548 %*                                                      *
549 \subsection{Looking up fixities}
550 %*                                                      *
551 %*********************************************************
552
553 This has to be in RnIfaces (or RnHiFiles) because it calls loadHomeInterface
554
555 \begin{code}
556 lookupFixityRn :: Name -> RnMS Fixity
557 lookupFixityRn name
558   | isLocallyDefined name
559   = getFixityEnv                        `thenRn` \ local_fix_env ->
560     returnRn (lookupLocalFixity local_fix_env name)
561
562   | otherwise   -- Imported
563       -- For imported names, we have to get their fixities by doing a loadHomeInterface,
564       -- and consulting the Ifaces that comes back from that, because the interface
565       -- file for the Name might not have been loaded yet.  Why not?  Suppose you import module A,
566       -- which exports a function 'f', which is defined in module B.  Then B isn't loaded
567       -- right away (after all, it's possible that nothing from B will be used).
568       -- When we come across a use of 'f', we need to know its fixity, and it's then,
569       -- and only then, that we load B.hi.  That is what's happening here.
570   = getHomeIfaceTableRn                 `thenRn` \ hit ->
571     loadHomeInterface doc name          `thenRn` \ ifaces ->
572     case lookupTable hit (iPIT ifaces) name of
573         Just iface -> returnRn (lookupNameEnv (mi_fixities iface) name `orElse` defaultFixity)
574         Nothing    -> returnRn defaultFixity
575   where
576     doc = ptext SLIT("Checking fixity for") <+> ppr name
577 \end{code}
578
579
580 %*********************************************************
581 %*                                                       *
582 \subsection{Errors}
583 %*                                                       *
584 %*********************************************************
585
586 \begin{code}
587 noIfaceErr mod_name boot_file
588   = ptext SLIT("Could not find interface file for") <+> quotes (ppr mod_name)
589         -- We used to print the search path, but we can't do that
590         -- now, because it's hidden inside the finder.
591         -- Maybe the finder should expose more functions.
592
593 badIfaceFile file err
594   = vcat [ptext SLIT("Bad interface file:") <+> text file, 
595           nest 4 err]
596
597 hiModuleNameMismatchWarn :: Module -> Module  -> Message
598 hiModuleNameMismatchWarn requested_mod read_mod = 
599     hsep [ ptext SLIT("Something is amiss; requested module name")
600          , ppr (moduleName requested_mod)
601          , ptext SLIT("differs from name found in the interface file")
602          , ppr read_mod
603          ]
604
605 warnRedundantSourceImport mod_name
606   = ptext SLIT("Unnecessary {- SOURCE -} in the import of module")
607           <+> quotes (ppr mod_name)
608 \end{code}
609