2020749a7fabb9d8bdc70812ddf6d6e46e005116
[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         readIface, 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         ( ModuleLocation(..),
22                           ModIface(..), emptyModIface,
23                           VersionInfo(..),
24                           lookupIfaceByModName, 
25                           ImportVersion, WhetherHasOrphans, IsBootInterface,
26                           DeclsMap, GatedDecl, IfaceInsts, IfaceRules,
27                           AvailInfo, GenAvailInfo(..), Avails, Deprecations(..)
28                          )
29 import HsSyn            ( TyClDecl(..), InstDecl(..),
30                           HsType(..), FixitySig(..), RuleDecl(..),
31                           tyClDeclNames, tyClDeclSysNames
32                         )
33 import RdrHsSyn         ( RdrNameTyClDecl, RdrNameInstDecl, RdrNameRuleDecl,
34                           extractHsTyRdrNames 
35                         )
36 import BasicTypes       ( Version, defaultFixity )
37 import RnEnv
38 import RnMonad
39 import ParseIface       ( parseIface, IfaceStuff(..) )
40
41 import Name             ( Name {-instance NamedThing-}, nameOccName,
42                           nameModule, isLocalName, nameIsLocalOrFrom,
43                           NamedThing(..),
44                          )
45 import Name             ( mkNameEnv, extendNameEnv )
46 import Module           ( Module, 
47                           moduleName, isHomeModule,
48                           ModuleName, WhereFrom(..),
49                           extendModuleEnv, mkVanillaModule
50                         )
51 import RdrName          ( RdrName, rdrNameOcc )
52 import SrcLoc           ( mkSrcLoc )
53 import Maybes           ( maybeToBool, orElse )
54 import StringBuffer     ( hGetStringBuffer )
55 import FastString       ( mkFastString )
56 import ErrUtils         ( Message )
57 import Finder           ( findModule )
58 import Lex
59 import FiniteMap
60 import Outputable
61 import Bag
62 import Config
63
64 import Directory
65 \end{code}
66
67
68 %*********************************************************
69 %*                                                      *
70 \subsection{Loading a new interface file}
71 %*                                                      *
72 %*********************************************************
73
74 \begin{code}
75 loadHomeInterface :: SDoc -> Name -> RnM d ModIface
76 loadHomeInterface doc_str name
77   = ASSERT2( not (isLocalName name), ppr name <+> parens doc_str )
78     loadInterface doc_str (moduleName (nameModule name)) ImportBySystem
79
80 loadOrphanModules :: [ModuleName] -> RnM d ()
81 loadOrphanModules mods
82   | null mods = returnRn ()
83   | otherwise = traceRn (text "Loading orphan modules:" <+> 
84                          fsep (map ppr mods))                   `thenRn_` 
85                 mapRn_ load mods                                `thenRn_`
86                 returnRn ()
87   where
88     load mod   = loadInterface (mk_doc mod) mod ImportBySystem
89     mk_doc mod = ppr mod <+> ptext SLIT("is a orphan-instance module")
90
91 loadInterface :: SDoc -> ModuleName -> WhereFrom -> RnM d ModIface
92 loadInterface doc mod from 
93   = tryLoadInterface doc mod from       `thenRn` \ (ifaces, maybe_err) ->
94     case maybe_err of
95         Nothing  -> returnRn ifaces
96         Just err -> failWithRn ifaces err
97
98 tryLoadInterface :: SDoc -> ModuleName -> WhereFrom -> RnM d (ModIface, Maybe Message)
99   -- Returns (Just err) if an error happened
100   -- It *doesn't* add an error to the monad, because sometimes it's ok to fail...
101   -- Specifically, when we read the usage information from an interface file,
102   -- we try to read the interfaces it mentions.  But it's OK to fail; perhaps
103   -- the module has changed, and that interface is no longer used.
104   
105   -- tryLoadInterface guarantees to return with iImpModInfo m --> (..., True)
106   -- (If the load fails, we plug in a vanilla placeholder)
107 tryLoadInterface doc_str mod_name from
108  = getHomeIfaceTableRn          `thenRn` \ hit ->
109    getIfacesRn                  `thenRn` \ ifaces@(Ifaces { iPIT = pit }) ->
110
111         -- CHECK WHETHER WE HAVE IT ALREADY
112    case lookupIfaceByModName hit pit mod_name of {
113         Just iface |  case from of
114                         ImportByUser       -> not (mi_boot iface)
115                         ImportByUserSource -> mi_boot iface
116                         ImportBySystem     -> True
117                    -> returnRn (iface, Nothing) ;       -- Already loaded
118                         -- The not (mi_boot iface) test checks that the already-loaded
119                         -- interface isn't a boot iface.  This can conceivably happen,
120                         -- if the version checking happened to load a boot interface
121                         -- before we got to real imports.  
122         other       -> 
123
124    let
125         mod_map  = iImpModInfo ifaces
126         mod_info = lookupFM mod_map mod_name
127
128         hi_boot_file 
129           = case (from, mod_info) of
130                 (ImportByUser,       _)             -> False    -- Not hi-boot
131                 (ImportByUserSource, _)             -> True     -- hi-boot
132                 (ImportBySystem, Just (_, is_boot)) -> is_boot
133                 (ImportBySystem, Nothing)           -> False
134                         -- We're importing a module we know absolutely
135                         -- nothing about, so we assume it's from
136                         -- another package, where we aren't doing 
137                         -- dependency tracking. So it won't be a hi-boot file.
138
139         redundant_source_import 
140           = case (from, mod_info) of 
141                 (ImportByUserSource, Just (_,False)) -> True
142                 other                                -> False
143    in
144
145         -- Issue a warning for a redundant {- SOURCE -} import
146         -- NB that we arrange to read all the ordinary imports before 
147         -- any of the {- SOURCE -} imports
148    warnCheckRn  (not redundant_source_import)
149                 (warnRedundantSourceImport mod_name)    `thenRn_`
150
151         -- READ THE MODULE IN
152    findAndReadIface doc_str mod_name hi_boot_file   `thenRn` \ read_result ->
153    case read_result of {
154         Left err ->     -- Not found, so add an empty export env to the Ifaces map
155                         -- so that we don't look again
156            let
157                 fake_mod    = mkVanillaModule mod_name
158                 fake_iface  = emptyModIface fake_mod
159                 new_ifaces  = ifaces { iPIT = extendModuleEnv pit fake_mod fake_iface }
160            in
161            setIfacesRn new_ifaces               `thenRn_`
162            returnRn (fake_iface, Just err) ;
163
164         -- Found and parsed!
165         Right (mod, iface) ->
166
167         -- LOAD IT INTO Ifaces
168
169         -- NB: *first* we do loadDecl, so that the provenance of all the locally-defined
170         ---    names is done correctly (notably, whether this is an .hi file or .hi-boot file).
171         --     If we do loadExport first the wrong info gets into the cache (unless we
172         --      explicitly tag each export which seems a bit of a bore)
173
174
175         -- Sanity check.  If we're system-importing a module we know nothing at all
176         -- about, it should be from a different package to this one
177     WARN( not (maybeToBool mod_info) && 
178           case from of { ImportBySystem -> True; other -> False } &&
179           isHomeModule mod,
180           ppr mod )
181
182     loadDecls mod               (iDecls ifaces)   (pi_decls iface)      `thenRn` \ (decls_vers, new_decls) ->
183     loadRules mod               (iRules ifaces)   (pi_rules iface)      `thenRn` \ (rule_vers, new_rules) ->
184     loadInstDecls mod           (iInsts ifaces)   (pi_insts iface)      `thenRn` \ new_insts ->
185     loadExports                                   (pi_exports iface)    `thenRn` \ (export_vers, avails) ->
186     loadFixDecls mod                              (pi_fixity iface)     `thenRn` \ fix_env ->
187     loadDeprecs mod                               (pi_deprecs iface)    `thenRn` \ deprec_env ->
188     let
189         version = VersionInfo { vers_module  = pi_vers iface, 
190                                 vers_exports = export_vers,
191                                 vers_rules = rule_vers,
192                                 vers_decls = decls_vers }
193
194         -- For an explicit user import, add to mod_map info about
195         -- the things the imported module depends on, extracted
196         -- from its usage info; and delete the module itself, which is now in the PIT
197         mod_map1 = case from of
198                         ImportByUser -> addModDeps mod is_loaded (pi_usages iface) mod_map
199                         other        -> mod_map
200         mod_map2 = delFromFM mod_map1 mod_name
201         is_loaded m = maybeToBool (lookupIfaceByModName hit pit m)
202
203         -- Now add info about this module to the PIT
204         has_orphans = pi_orphan iface
205         new_pit   = extendModuleEnv pit mod mod_iface
206         mod_iface = ModIface { mi_module = mod, mi_version = version,
207                                mi_orphan = has_orphans, mi_boot = hi_boot_file,
208                                mi_exports = avails, 
209                                mi_fixities = fix_env, mi_deprecs = deprec_env,
210                                mi_usages  = [], -- Will be filled in later
211                                mi_decls   = panic "No mi_decls in PIT",
212                                mi_globals = mkIfaceGlobalRdrEnv avails
213                     }
214
215         new_ifaces = ifaces { iPIT        = new_pit,
216                               iDecls      = new_decls,
217                               iInsts      = new_insts,
218                               iRules      = new_rules,
219                               iImpModInfo = mod_map2  }
220     in
221     setIfacesRn new_ifaces              `thenRn_`
222     returnRn (mod_iface, Nothing)
223     }}
224
225 -----------------------------------------------------
226 --      Adding module dependencies from the 
227 --      import decls in the interface file
228 -----------------------------------------------------
229
230 addModDeps :: Module 
231            -> (ModuleName -> Bool)      -- True for module interfaces
232            -> [ImportVersion a] 
233            -> ImportedModuleInfo -> ImportedModuleInfo
234 -- (addModDeps M ivs deps)
235 -- We are importing module M, and M.hi contains 'import' decls given by ivs
236 addModDeps mod is_loaded new_deps mod_deps
237   = foldr add mod_deps filtered_new_deps
238   where
239         -- Don't record dependencies when importing a module from another package
240         -- Except for its descendents which contain orphans,
241         -- and in that case, forget about the boot indicator
242     filtered_new_deps :: [(ModuleName, (WhetherHasOrphans, IsBootInterface))]
243     filtered_new_deps
244         | isHomeModule mod 
245                             = [ (imp_mod, (has_orphans, is_boot))
246                               | (imp_mod, has_orphans, is_boot, _) <- new_deps,
247                                 not (is_loaded imp_mod)
248                               ]                       
249         | otherwise         = [ (imp_mod, (True, False))
250                               | (imp_mod, has_orphans, _, _) <- new_deps,
251                                 not (is_loaded imp_mod) && has_orphans
252                               ]
253     add (imp_mod, dep) deps = addToFM_C combine deps imp_mod dep
254
255     combine old@(old_has_orphans, old_is_boot) new@(new_has_orphans, new_is_boot)
256         | old_is_boot = new     -- Record the best is_boot info
257         | otherwise   = old
258
259 -----------------------------------------------------
260 --      Loading the export list
261 -----------------------------------------------------
262
263 loadExports :: (Version, [ExportItem]) -> RnM d (Version, [(ModuleName,Avails)])
264 loadExports (vers, items)
265   = getModuleRn                                 `thenRn` \ this_mod ->
266     mapRn (loadExport this_mod) items           `thenRn` \ avails_s ->
267     returnRn (vers, avails_s)
268
269
270 loadExport :: Module -> ExportItem -> RnM d (ModuleName, Avails)
271 loadExport this_mod (mod, entities)
272   = mapRn (load_entity mod) entities    `thenRn` \ avails ->
273     returnRn (mod, avails)
274   where
275     load_entity mod (Avail occ)
276       = newGlobalName mod occ   `thenRn` \ name ->
277         returnRn (Avail name)
278     load_entity mod (AvailTC occ occs)
279       = newGlobalName mod occ           `thenRn` \ name ->
280         mapRn (newGlobalName 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, n_slurped) decls
293   = foldlRn (loadDecl mod) (emptyNameEnv, decls_map) decls      `thenRn` \ (vers, decls_map') -> 
294     returnRn (vers, (decls_map', n_slurped))
295
296 loadDecl mod (version_map, decls_map) (version, decl)
297   = getTyClDeclBinders mod decl `thenRn` \ (avail, sys_names) ->
298     let
299         full_avail    = case avail of
300                           Avail n -> avail
301                           AvailTC n ns -> AvailTC n (sys_names ++ ns)
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
311 -----------------------------------------------------
312 --      Loading fixity decls
313 -----------------------------------------------------
314
315 loadFixDecls mod decls
316   = mapRn (loadFixDecl mod_name) decls  `thenRn` \ to_add ->
317     returnRn (mkNameEnv to_add)
318   where
319     mod_name = moduleName mod
320
321 loadFixDecl mod_name sig@(FixitySig rdr_name fixity loc)
322   = newGlobalName mod_name (rdrNameOcc rdr_name)        `thenRn` \ name ->
323     returnRn (name, fixity)
324
325
326 -----------------------------------------------------
327 --      Loading instance decls
328 -----------------------------------------------------
329
330 loadInstDecls :: Module
331               -> IfaceInsts
332               -> [RdrNameInstDecl]
333               -> RnM d IfaceInsts
334 loadInstDecls mod (insts, n_slurped) decls
335   = setModuleRn mod $
336     foldlRn (loadInstDecl mod) insts decls      `thenRn` \ insts' ->
337     returnRn (insts', n_slurped)
338
339
340 loadInstDecl mod insts decl@(InstDecl inst_ty _ _ _ _)
341   =     -- Find out what type constructors and classes are "gates" for the
342         -- instance declaration.  If all these "gates" are slurped in then
343         -- we should slurp the instance decl too.
344         -- 
345         -- We *don't* want to count names in the context part as gates, though.
346         -- For example:
347         --              instance Foo a => Baz (T a) where ...
348         --
349         -- Here the gates are Baz and T, but *not* Foo.
350     let 
351         munged_inst_ty = removeContext inst_ty
352         free_names     = extractHsTyRdrNames munged_inst_ty
353     in
354     mapRn lookupIfaceName free_names    `thenRn` \ gate_names ->
355     returnRn ((gate_names, (mod, decl)) `consBag` insts)
356
357
358 -- In interface files, the instance decls now look like
359 --      forall a. Foo a -> Baz (T a)
360 -- so we have to strip off function argument types as well
361 -- as the bit before the '=>' (which is always empty in interface files)
362 removeContext (HsForAllTy tvs cxt ty) = HsForAllTy tvs [] (removeFuns ty)
363 removeContext ty                      = removeFuns ty
364
365 removeFuns (HsFunTy _ ty) = removeFuns ty
366 removeFuns ty               = ty
367
368
369 -----------------------------------------------------
370 --      Loading Rules
371 -----------------------------------------------------
372
373 loadRules :: Module -> IfaceRules 
374           -> (Version, [RdrNameRuleDecl])
375           -> RnM d (Version, IfaceRules)
376 loadRules mod (rule_bag, n_slurped) (version, rules)
377   | null rules || opt_IgnoreIfacePragmas 
378   = returnRn (version, (rule_bag, n_slurped))
379   | otherwise
380   = setModuleRn mod                     $
381     mapRn (loadRule mod) rules          `thenRn` \ new_rules ->
382     returnRn (version, (rule_bag `unionBags` listToBag new_rules, n_slurped))
383
384 loadRule :: Module -> RdrNameRuleDecl -> RnM d (GatedDecl RdrNameRuleDecl)
385 -- "Gate" the rule simply by whether the rule variable is
386 -- needed.  We can refine this later.
387 loadRule mod decl@(IfaceRule _ _ var _ _ src_loc)
388   = lookupIfaceName var         `thenRn` \ var_name ->
389     returnRn ([var_name], (mod, decl))
390
391
392 -----------------------------------------------------
393 --      Loading Deprecations
394 -----------------------------------------------------
395
396 loadDeprecs :: Module -> IfaceDeprecs -> RnM d Deprecations
397 loadDeprecs m Nothing                                  = returnRn NoDeprecs
398 loadDeprecs m (Just (Left txt))  = returnRn (DeprecAll txt)
399 loadDeprecs m (Just (Right prs)) = setModuleRn m                                $
400                                    foldlRn loadDeprec emptyNameEnv prs  `thenRn` \ env ->
401                                    returnRn (DeprecSome env)
402 loadDeprec deprec_env (n, txt)
403   = lookupIfaceName n           `thenRn` \ name ->
404     traceRn (text "Loaded deprecation(s) for" <+> ppr name <> colon <+> ppr txt) `thenRn_`
405     returnRn (extendNameEnv deprec_env name (name,txt))
406 \end{code}
407
408
409 %*********************************************************
410 %*                                                      *
411 \subsection{Getting binders out of a declaration}
412 %*                                                      *
413 %*********************************************************
414
415 @getDeclBinders@ returns the names for a @RdrNameHsDecl@.
416 It's used for both source code (from @availsFromDecl@) and interface files
417 (from @loadDecl@).
418
419 It doesn't deal with source-code specific things: @ValD@, @DefD@.  They
420 are handled by the sourc-code specific stuff in @RnNames@.
421
422 \begin{code}
423 getTyClDeclBinders
424         :: Module
425         -> RdrNameTyClDecl
426         -> RnM d (AvailInfo, [Name])    -- The [Name] are the system names
427
428 -----------------
429 getTyClDeclBinders mod (IfaceSig {tcdName = var, tcdLoc = src_loc})
430   = newTopBinder mod var src_loc                        `thenRn` \ var_name ->
431     returnRn (Avail var_name, [])
432
433 getTyClDeclBinders mod tycl_decl
434   = new_top_bndrs mod (tyClDeclNames tycl_decl)         `thenRn` \ names@(main_name:_) ->
435     new_top_bndrs mod (tyClDeclSysNames tycl_decl)      `thenRn` \ sys_names ->
436     returnRn (AvailTC main_name names, sys_names)
437
438 -----------------
439 new_top_bndrs mod names_w_locs
440   = sequenceRn [newTopBinder mod name loc | (name,loc) <- names_w_locs]
441 \end{code}
442
443
444 %*********************************************************
445 %*                                                      *
446 \subsection{Reading an interface file}
447 %*                                                      *
448 %*********************************************************
449
450 \begin{code}
451 findAndReadIface :: SDoc -> ModuleName 
452                  -> IsBootInterface     -- True  <=> Look for a .hi-boot file
453                                         -- False <=> Look for .hi file
454                  -> RnM d (Either Message (Module, ParsedIface))
455         -- Nothing <=> file not found, or unreadable, or illegible
456         -- Just x  <=> successfully found and parsed 
457
458 findAndReadIface doc_str mod_name hi_boot_file
459   = traceRn trace_msg                   `thenRn_`
460
461     ioToRnM (findModule mod_name)       `thenRn` \ maybe_found ->
462     case maybe_found of
463
464       Right (Just (wanted_mod,locn))
465         -> mkHiPath hi_boot_file locn `thenRn` \ file -> 
466            readIface file `thenRn` \ read_result ->
467            case read_result of
468                 Left bad -> returnRn (Left bad)
469                 Right iface 
470                    -> let read_mod = pi_mod iface
471                       in warnCheckRn (wanted_mod == read_mod)
472                                      (hiModuleNameMismatchWarn wanted_mod 
473                                         read_mod) `thenRn_`
474                          returnRn (Right (wanted_mod, iface))
475         -- Can't find it
476       other   -> traceRn (ptext SLIT("...not found"))   `thenRn_`
477                  returnRn (Left (noIfaceErr mod_name hi_boot_file))
478
479   where
480     trace_msg = sep [hsep [ptext SLIT("Reading"), 
481                            if hi_boot_file then ptext SLIT("[boot]") else empty,
482                            ptext SLIT("interface for"), 
483                            ppr mod_name <> semi],
484                      nest 4 (ptext SLIT("reason:") <+> doc_str)]
485
486 mkHiPath hi_boot_file locn
487   | hi_boot_file = 
488         ioToRnM_no_fail (doesFileExist hi_boot_ver_path) `thenRn` \ b ->
489         if b then returnRn hi_boot_ver_path
490              else returnRn hi_boot_path
491   | otherwise    = returnRn hi_path
492         where (Just hi_path)   = ml_hi_file locn
493               hi_boot_path     = hi_path ++ "-boot"
494               hi_boot_ver_path = hi_path ++ "-boot-" ++ cHscIfaceFileVersion
495 \end{code}
496
497 @readIface@ tries just the one file.
498
499 \begin{code}
500 readIface :: String -> RnM d (Either Message ParsedIface)
501         -- Nothing <=> file not found, or unreadable, or illegible
502         -- Just x  <=> successfully found and parsed 
503 readIface file_path
504   = --ioToRnM (putStrLn ("reading iface " ++ file_path)) `thenRn_`
505     traceRn (ptext SLIT("readIFace") <+> text file_path)        `thenRn_` 
506
507     ioToRnM (hGetStringBuffer False file_path)                  `thenRn` \ read_result ->
508     case read_result of {
509         Left io_error  -> bale_out (text (show io_error)) ;
510         Right contents -> 
511
512     case parseIface contents init_parser_state of
513         POk _ (PIface iface) -> returnRn (Right iface)
514         PFailed err          -> bale_out err
515         parse_result         -> bale_out empty
516                 -- This last case can happen if the interface file is (say) empty
517                 -- in which case the parser thinks it looks like an IdInfo or
518                 -- something like that.  Just an artefact of the fact that the
519                 -- parser is used for several purposes at once.
520     }
521   where
522     init_parser_state = PState{ bol = 0#, atbol = 1#,
523                                 context = [],
524                                 glasgow_exts = 1#,
525                                 loc = mkSrcLoc (mkFastString file_path) 1 }
526
527     bale_out err = returnRn (Left (badIfaceFile file_path err))
528 \end{code}
529
530
531 %*********************************************************
532 %*                                                      *
533 \subsection{Looking up fixities}
534 %*                                                      *
535 %*********************************************************
536
537 @lookupFixityRn@ has to be in RnIfaces (or RnHiFiles) because 
538 it calls @loadHomeInterface@.
539
540 lookupFixity is a bit strange.  
541
542 * Nested local fixity decls are put in the local fixity env, which we
543   find with getFixtyEnv
544
545 * Imported fixities are found in the HIT or PIT
546
547 * Top-level fixity decls in this module may be for Names that are
548     either  Global         (constructors, class operations)
549     or      Local/Exported (everything else)
550   (See notes with RnNames.getLocalDeclBinders for why we have this split.)
551   We put them all in the local fixity environment
552
553 \begin{code}
554 lookupFixityRn :: Name -> RnMS Fixity
555 lookupFixityRn name
556   = getModuleRn                         `thenRn` \ this_mod ->
557     if nameIsLocalOrFrom this_mod name
558     then        -- It's defined in this module
559         getFixityEnv                    `thenRn` \ local_fix_env ->
560         returnRn (lookupLocalFixity local_fix_env name)
561
562     else        -- It's 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         loadHomeInterface doc name              `thenRn` \ iface ->
571         returnRn (lookupNameEnv (mi_fixities iface) name `orElse` defaultFixity)
572   where
573     doc      = ptext SLIT("Checking fixity for") <+> ppr name
574 \end{code}
575
576
577 %*********************************************************
578 %*                                                       *
579 \subsection{Errors}
580 %*                                                       *
581 %*********************************************************
582
583 \begin{code}
584 noIfaceErr mod_name boot_file
585   = ptext SLIT("Could not find interface file for") <+> quotes (ppr mod_name)
586         -- We used to print the search path, but we can't do that
587         -- now, because it's hidden inside the finder.
588         -- Maybe the finder should expose more functions.
589
590 badIfaceFile file err
591   = vcat [ptext SLIT("Bad interface file:") <+> text file, 
592           nest 4 err]
593
594 hiModuleNameMismatchWarn :: Module -> Module  -> Message
595 hiModuleNameMismatchWarn requested_mod read_mod = 
596     hsep [ ptext SLIT("Something is amiss; requested module name")
597          , ppr (moduleName requested_mod)
598          , ptext SLIT("differs from name found in the interface file")
599          , ppr read_mod
600          ]
601
602 warnRedundantSourceImport mod_name
603   = ptext SLIT("Unnecessary {- SOURCE -} in the import of module")
604           <+> quotes (ppr mod_name)
605 \end{code}
606