2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
4 \section[RnMonad]{The monad used by the renamer}
21 #include "HsVersions.h"
23 #if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 405
24 import IOExts ( fixIO )
25 #elif defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 302
26 import PrelIOBase ( fixIO ) -- Should be in GlaExts
28 import IOBase ( fixIO )
30 import IOExts ( IORef, newIORef, readIORef, writeIORef, unsafePerformIO )
34 import RnHsSyn ( RenamedFixitySig, RenamedDeprecation )
35 import BasicTypes ( Version )
36 import SrcLoc ( noSrcLoc )
37 import ErrUtils ( addShortErrLocLine, addShortWarnLocLine,
38 pprBagOfErrors, ErrMsg, WarnMsg, Message
40 import Name ( Name, OccName, NamedThing(..),
41 isLocallyDefinedName, nameModule, nameOccName,
42 decode, mkLocalName, mkUnboundName
44 import Module ( Module, ModuleName, ModuleHiMap, SearchPath, WhereFrom,
45 mkModuleHiMaps, moduleName, mkVanillaModule, mkSearchPath
48 import RdrName ( RdrName, dummyRdrVarName, rdrNameOcc )
49 import CmdLineOpts ( opt_D_dump_rn_trace, opt_HiMap )
50 import PrelInfo ( builtinNames )
51 import TysWiredIn ( boolTyCon )
52 import SrcLoc ( SrcLoc, mkGeneratedSrcLoc )
53 import Unique ( Unique, getUnique, unboundKey )
54 import UniqFM ( UniqFM )
55 import FiniteMap ( FiniteMap, emptyFM, bagToFM, lookupFM, addToFM, addListToFM,
56 addListToFM_C, addToFM_C, eltsFM, fmToList
58 import Bag ( Bag, mapBag, emptyBag, isEmptyBag, snocBag )
59 import Maybes ( mapMaybe )
66 infixr 9 `thenRn`, `thenRn_`
70 %************************************************************************
72 \subsection{Somewhat magical interface to other monads}
74 %************************************************************************
77 ioToRnM :: IO r -> RnM d (Either IOError r)
78 ioToRnM io rn_down g_down = (io >>= \ ok -> return (Right ok))
80 (\ err -> return (Left err))
82 traceRn :: SDoc -> RnM d ()
83 traceRn msg | opt_D_dump_rn_trace = putDocRn msg
84 | otherwise = returnRn ()
86 putDocRn :: SDoc -> RnM d ()
87 putDocRn msg = ioToRnM (printErrs msg) `thenRn_`
92 %************************************************************************
94 \subsection{Data types}
96 %************************************************************************
98 %===================================================
99 \subsubsection{ MONAD TYPES}
100 %===================================================
103 type RnM d r = RnDown -> d -> IO r
104 type RnMS r = RnM SDown r -- Renaming source
105 type RnMG r = RnM () r -- Getting global names etc
108 data RnDown = RnDown {
109 rn_mod :: ModuleName,
111 rn_ns :: IORef RnNameSupply,
112 rn_errs :: IORef (Bag WarnMsg, Bag ErrMsg),
113 rn_ifaces :: IORef Ifaces,
114 rn_hi_maps :: (SearchPath, -- For error messages
115 ModuleHiMap, -- for .hi files
116 ModuleHiMap) -- for .hi-boot files
119 -- For renaming source code
123 rn_genv :: GlobalRdrEnv,
124 -- Global envt; the fixity component gets extended
125 -- with local fixity decls
127 rn_lenv :: LocalRdrEnv, -- Local name envt
128 -- Does *not* include global name envt; may shadow it
129 -- Includes both ordinary variables and type variables;
130 -- they are kept distinct because tyvar have a different
131 -- occurrence contructor (Name.TvOcc)
132 -- We still need the unsullied global name env so that
133 -- we can look up record field names
135 rn_fixenv :: FixityEnv -- Local fixities
136 -- The global fixities are held in the
137 -- rn_ifaces field. Why? See the comments
138 -- with RnIfaces.lookupFixity
141 data RnMode = SourceMode -- Renaming source code
142 | InterfaceMode -- Renaming interface declarations.
145 %===================================================
146 \subsubsection{ ENVIRONMENTS}
147 %===================================================
150 --------------------------------
151 type RdrNameEnv a = FiniteMap RdrName a
152 type GlobalRdrEnv = RdrNameEnv [Name] -- The list is because there may be name clashes
153 -- These only get reported on lookup,
154 -- not on construction
155 type LocalRdrEnv = RdrNameEnv Name
157 emptyRdrEnv :: RdrNameEnv a
158 lookupRdrEnv :: RdrNameEnv a -> RdrName -> Maybe a
159 addListToRdrEnv :: RdrNameEnv a -> [(RdrName,a)] -> RdrNameEnv a
160 extendRdrEnv :: RdrNameEnv a -> RdrName -> a -> RdrNameEnv a
162 emptyRdrEnv = emptyFM
163 lookupRdrEnv = lookupFM
164 addListToRdrEnv = addListToFM
166 extendRdrEnv = addToFM
167 rdrEnvToList = fmToList
169 --------------------------------
170 type NameEnv a = UniqFM a -- Domain is Name
172 emptyNameEnv :: NameEnv a
173 nameEnvElts :: NameEnv a -> [a]
174 addToNameEnv_C :: (a->a->a) -> NameEnv a -> Name -> a -> NameEnv a
175 addToNameEnv :: NameEnv a -> Name -> a -> NameEnv a
176 plusNameEnv :: NameEnv a -> NameEnv a -> NameEnv a
177 plusNameEnv_C :: (a->a->a) -> NameEnv a -> NameEnv a -> NameEnv a
178 extendNameEnv :: NameEnv a -> [(Name,a)] -> NameEnv a
179 lookupNameEnv :: NameEnv a -> Name -> Maybe a
180 delFromNameEnv :: NameEnv a -> Name -> NameEnv a
181 elemNameEnv :: Name -> NameEnv a -> Bool
182 unitNameEnv :: Name -> a -> NameEnv a
184 emptyNameEnv = emptyUFM
185 nameEnvElts = eltsUFM
186 addToNameEnv_C = addToUFM_C
187 addToNameEnv = addToUFM
188 plusNameEnv = plusUFM
189 plusNameEnv_C = plusUFM_C
190 extendNameEnv = addListToUFM
191 lookupNameEnv = lookupUFM
192 delFromNameEnv = delFromUFM
193 elemNameEnv = elemUFM
194 unitNameEnv = unitUFM
196 --------------------------------
197 type FixityEnv = NameEnv RenamedFixitySig
198 -- We keep the whole fixity sig so that we
199 -- can report line-number info when there is a duplicate
200 -- fixity declaration
202 --------------------------------
203 type DeprecationEnv = NameEnv DeprecTxt
207 --------------------------------
211 , FiniteMap String Int
212 -- This is used as a name supply for dictionary functions
213 -- From the inst decl we derive a string, usually by glomming together
214 -- the class and tycon name -- but it doesn't matter exactly how;
215 -- this map then gives a unique int for each inst decl with that
216 -- string. (In Haskell 98 there can only be one,
217 -- but not so in more extended versions; also class CC type T
218 -- and class C type TT might both give the string CCT
220 -- We could just use one Int for all the instance decls, but this
221 -- way the uniques change less when you add an instance decl,
222 -- hence less recompilation
224 , FiniteMap (ModuleName, OccName) Name
225 -- Ensures that one (module,occname) pair gets one unique
226 , FiniteMap OccName Name
227 -- Ensures that one implicit parameter name gets one unique
231 --------------------------------
232 data ExportEnv = ExportEnv Avails Fixities [ModuleName]
233 -- The list of modules is the modules exported
234 -- with 'module M' in the export list
236 type Avails = [AvailInfo]
237 type Fixities = [(Name, Fixity)]
239 type ExportAvails = (FiniteMap ModuleName Avails,
240 -- Used to figure out "module M" export specifiers
241 -- Includes avails only from *unqualified* imports
242 -- (see 1.4 Report Section 5.1.1)
244 AvailEnv) -- Used to figure out all other export specifiers.
247 data GenAvailInfo name = Avail name -- An ordinary identifier
248 | AvailTC name -- The name of the type or class
249 [name] -- The available pieces of type/class.
250 -- NB: If the type or class is itself
251 -- to be in scope, it must be in this list.
252 -- Thus, typically: AvailTC Eq [Eq, ==, /=]
254 type AvailEnv = NameEnv AvailInfo -- Maps a Name to the AvailInfo that contains it
255 type AvailInfo = GenAvailInfo Name
256 type RdrAvailInfo = GenAvailInfo OccName
259 %===================================================
260 \subsubsection{ INTERFACE FILE STUFF}
261 %===================================================
264 type ExportItem = (ModuleName, [RdrAvailInfo])
265 type VersionInfo name = [ImportVersion name]
267 type ImportVersion name = (ModuleName, Version,
268 WhetherHasOrphans, IsBootInterface, WhatsImported name)
270 type WhetherHasOrphans = Bool
272 -- * an instance decl in a module other than the defn module for
273 -- one of the tycons or classes in the instance head
274 -- * a transformation rule in a module other than the one defining
275 -- the function in the head of the rule.
277 type IsBootInterface = Bool
279 data WhatsImported name = Everything
280 | Specifically [LocalVersion name] -- List guaranteed non-empty
282 -- ("M", hif, ver, Everything) means there was a "module M" in
283 -- this module's export list, so we just have to go by M's version, "ver",
284 -- not the list of LocalVersions.
287 type LocalVersion name = (name, Version)
291 pi_mod :: Module, -- Complete with package info
292 pi_vers :: Version, -- Module version number
293 pi_orphan :: WhetherHasOrphans, -- Whether this module has orphans
294 pi_usages :: [ImportVersion OccName], -- Usages
295 pi_exports :: [ExportItem], -- Exports
296 pi_decls :: [(Version, RdrNameHsDecl)], -- Local definitions
297 pi_insts :: [RdrNameInstDecl], -- Local instance declarations
298 pi_rules :: [RdrNameRuleDecl], -- Rules
299 pi_deprecs :: [RdrNameDeprecation] -- Deprecations
302 data InterfaceDetails
303 = InterfaceDetails WhetherHasOrphans
304 (VersionInfo Name) -- Version information for what this module imports
305 ExportEnv -- What modules this one depends on
309 -- needed by Main to fish out the fixities assoc list.
310 getIfaceFixities :: InterfaceDetails -> Fixities
311 getIfaceFixities (InterfaceDetails _ _ (ExportEnv _ fs _) _) = fs
314 type RdrNamePragma = () -- Fudge for now
317 data Ifaces = Ifaces {
318 iImpModInfo :: ImportedModuleInfo,
319 -- Modules this one depends on: that is, the union
320 -- of the modules its *direct* imports depend on.
321 -- NB: The direct imports have .hi files that enumerate *all* the
322 -- dependencies (direct or not) of the imported module.
324 iDecls :: DeclsMap, -- A single, global map of Names to decls
326 iFixes :: FixityEnv, -- A single, global map of Names to fixities
327 -- See comments with RnIfaces.lookupFixity
330 -- All the names (whether "big" or "small", whether wired-in or not,
331 -- whether locally defined or not) that have been slurped in so far.
333 iVSlurp :: [(Name,Version)],
334 -- All the (a) non-wired-in (b) "big" (c) non-locally-defined
335 -- names that have been slurped in so far, with their versions.
336 -- This is used to generate the "usage" information for this module.
337 -- Subset of the previous field.
339 iInsts :: Bag GatedDecl,
340 -- The as-yet un-slurped instance decls; this bag is depleted when we
341 -- slurp an instance decl so that we don't slurp the same one twice.
342 -- Each is 'gated' by the names that must be available before
343 -- this instance decl is needed.
345 iRules :: Bag GatedDecl,
346 -- Ditto transformation rules
348 iDeprecs :: DeprecationEnv
351 type GatedDecl = (NameSet, (Module, RdrNameHsDecl))
353 type ImportedModuleInfo
354 = FiniteMap ModuleName (Version, WhetherHasOrphans, IsBootInterface,
355 Maybe (Module, WhereFrom, Avails))
356 -- Suppose the domain element is module 'A'
358 -- The first Bool is True if A contains
359 -- 'orphan' rules or instance decls
361 -- The second Bool is true if the interface file actually
362 -- read was an .hi-boot file
364 -- Nothing => A's interface not yet read, but this module has
365 -- imported a module, B, that itself depends on A
367 -- Just xx => A's interface has been read. The Module in
368 -- the Just has the correct Dll flag
370 -- This set is used to decide whether to look for
371 -- A.hi or A.hi-boot when importing A.f.
372 -- Basically, we look for A.hi if A is in the map, and A.hi-boot
375 type DeclsMap = NameEnv (Version, AvailInfo, Bool, (Module, RdrNameHsDecl))
376 -- A DeclsMap contains a binding for each Name in the declaration
377 -- including the constructors of a type decl etc.
378 -- The Bool is True just for the 'main' Name.
382 %************************************************************************
384 \subsection{Main monad code}
386 %************************************************************************
389 initRn :: ModuleName -> UniqSupply -> SearchPath -> SrcLoc
391 -> IO (r, Bag ErrMsg, Bag WarnMsg)
393 initRn mod us dirs loc do_rn = do
394 himaps <- mkModuleHiMaps dirs
395 names_var <- newIORef (us, emptyFM, builtins, emptyFM)
396 errs_var <- newIORef (emptyBag,emptyBag)
397 iface_var <- newIORef emptyIfaces
399 rn_down = RnDown { rn_loc = loc, rn_ns = names_var,
402 rn_ifaces = iface_var,
406 res <- do_rn rn_down ()
408 -- grab errors and return
409 (warns, errs) <- readIORef errs_var
411 return (res, errs, warns)
414 initRnMS :: GlobalRdrEnv -> FixityEnv -> RnMode -> RnMS r -> RnM d r
415 initRnMS rn_env fixity_env mode thing_inside rn_down g_down
417 s_down = SDown { rn_genv = rn_env, rn_lenv = emptyRdrEnv,
418 rn_fixenv = fixity_env, rn_mode = mode }
420 thing_inside rn_down s_down
422 initIfaceRnMS :: Module -> RnMS r -> RnM d r
423 initIfaceRnMS mod thing_inside
424 = initRnMS emptyRdrEnv emptyNameEnv InterfaceMode $
425 setModuleRn (moduleName mod) thing_inside
427 emptyIfaces :: Ifaces
428 emptyIfaces = Ifaces { iImpModInfo = emptyFM,
429 iDecls = emptyNameEnv,
430 iFixes = emptyNameEnv,
431 iSlurp = unitNameSet (mkUnboundName dummyRdrVarName),
432 -- Pretend that the dummy unbound name has already been
433 -- slurped. This is what's returned for an out-of-scope name,
434 -- and we don't want thereby to try to suck it in!
438 iDeprecs = emptyNameEnv
441 builtins :: FiniteMap (ModuleName,OccName) Name
444 mapBag (\ name -> ((moduleName (nameModule name), nameOccName name), name))
448 @renameSourceCode@ is used to rename stuff ``out-of-line'';
449 that is, not as part of the main renamer.
450 Sole examples: derived definitions,
451 which are only generated in the type checker.
453 The @RnNameSupply@ includes a @UniqueSupply@, so if you call it more than
454 once you must either split it, or install a fresh unique supply.
457 renameSourceCode :: ModuleName
462 renameSourceCode mod_name name_supply m
464 -- It's not really unsafe! When renaming source code we
465 -- only do any I/O if we need to read in a fixity declaration;
466 -- and that doesn't happen in pragmas etc
468 mkModuleHiMaps (mkSearchPath opt_HiMap) >>= \ himaps ->
469 newIORef name_supply >>= \ names_var ->
470 newIORef (emptyBag,emptyBag) >>= \ errs_var ->
472 rn_down = RnDown { rn_loc = mkGeneratedSrcLoc, rn_ns = names_var,
473 rn_errs = errs_var, rn_hi_maps = himaps,
475 rn_ifaces = panic "rnameSourceCode: rn_ifaces" -- Not required
477 s_down = SDown { rn_mode = InterfaceMode,
478 -- So that we can refer to PrelBase.True etc
479 rn_genv = emptyRdrEnv, rn_lenv = emptyRdrEnv,
480 rn_fixenv = emptyNameEnv }
482 m rn_down s_down >>= \ result ->
484 readIORef errs_var >>= \ (warns,errs) ->
486 (if not (isEmptyBag errs) then
487 pprTrace "Urk! renameSourceCode found errors" (display errs)
489 else if not (isEmptyBag warns) then
490 pprTrace "Note: renameSourceCode found warnings" (display warns)
498 display errs = pprBagOfErrors errs
500 {-# INLINE thenRn #-}
501 {-# INLINE thenRn_ #-}
502 {-# INLINE returnRn #-}
505 returnRn :: a -> RnM d a
506 thenRn :: RnM d a -> (a -> RnM d b) -> RnM d b
507 thenRn_ :: RnM d a -> RnM d b -> RnM d b
508 andRn :: (a -> a -> a) -> RnM d a -> RnM d a -> RnM d a
509 mapRn :: (a -> RnM d b) -> [a] -> RnM d [b]
510 mapRn_ :: (a -> RnM d b) -> [a] -> RnM d ()
511 mapMaybeRn :: (a -> RnM d (Maybe b)) -> [a] -> RnM d [b]
512 flatMapRn :: (a -> RnM d [b]) -> [a] -> RnM d [b]
513 sequenceRn :: [RnM d a] -> RnM d [a]
514 foldlRn :: (b -> a -> RnM d b) -> b -> [a] -> RnM d b
515 mapAndUnzipRn :: (a -> RnM d (b,c)) -> [a] -> RnM d ([b],[c])
516 fixRn :: (a -> RnM d a) -> RnM d a
518 returnRn v gdown ldown = return v
519 thenRn m k gdown ldown = m gdown ldown >>= \ r -> k r gdown ldown
520 thenRn_ m k gdown ldown = m gdown ldown >> k gdown ldown
521 fixRn m gdown ldown = fixIO (\r -> m r gdown ldown)
522 andRn combiner m1 m2 gdown ldown
523 = m1 gdown ldown >>= \ res1 ->
524 m2 gdown ldown >>= \ res2 ->
525 return (combiner res1 res2)
527 sequenceRn [] = returnRn []
528 sequenceRn (m:ms) = m `thenRn` \ r ->
529 sequenceRn ms `thenRn` \ rs ->
532 mapRn f [] = returnRn []
534 = f x `thenRn` \ r ->
535 mapRn f xs `thenRn` \ rs ->
538 mapRn_ f [] = returnRn ()
543 foldlRn k z [] = returnRn z
544 foldlRn k z (x:xs) = k z x `thenRn` \ z' ->
547 mapAndUnzipRn f [] = returnRn ([],[])
548 mapAndUnzipRn f (x:xs)
549 = f x `thenRn` \ (r1, r2) ->
550 mapAndUnzipRn f xs `thenRn` \ (rs1, rs2) ->
551 returnRn (r1:rs1, r2:rs2)
553 mapAndUnzip3Rn f [] = returnRn ([],[],[])
554 mapAndUnzip3Rn f (x:xs)
555 = f x `thenRn` \ (r1, r2, r3) ->
556 mapAndUnzip3Rn f xs `thenRn` \ (rs1, rs2, rs3) ->
557 returnRn (r1:rs1, r2:rs2, r3:rs3)
559 mapMaybeRn f [] = returnRn []
560 mapMaybeRn f (x:xs) = f x `thenRn` \ maybe_r ->
561 mapMaybeRn f xs `thenRn` \ rs ->
563 Nothing -> returnRn rs
564 Just r -> returnRn (r:rs)
566 flatMapRn f [] = returnRn []
567 flatMapRn f (x:xs) = f x `thenRn` \ r ->
568 flatMapRn f xs `thenRn` \ rs ->
574 %************************************************************************
576 \subsection{Boring plumbing for common part}
578 %************************************************************************
582 \subsubsection{ Errors and warnings}
583 %=====================
586 failWithRn :: a -> Message -> RnM d a
587 failWithRn res msg (RnDown {rn_errs = errs_var, rn_loc = loc}) l_down
588 = readIORef errs_var >>= \ (warns,errs) ->
589 writeIORef errs_var (warns, errs `snocBag` err) >>
592 err = addShortErrLocLine loc msg
594 warnWithRn :: a -> Message -> RnM d a
595 warnWithRn res msg (RnDown {rn_errs = errs_var, rn_loc = loc}) l_down
596 = readIORef errs_var >>= \ (warns,errs) ->
597 writeIORef errs_var (warns `snocBag` warn, errs) >>
600 warn = addShortWarnLocLine loc msg
602 addErrRn :: Message -> RnM d ()
603 addErrRn err = failWithRn () err
605 checkRn :: Bool -> Message -> RnM d () -- Check that a condition is true
606 checkRn False err = addErrRn err
607 checkRn True err = returnRn ()
609 warnCheckRn :: Bool -> Message -> RnM d () -- Check that a condition is true
610 warnCheckRn False err = addWarnRn err
611 warnCheckRn True err = returnRn ()
613 addWarnRn :: Message -> RnM d ()
614 addWarnRn warn = warnWithRn () warn
616 checkErrsRn :: RnM d Bool -- True <=> no errors so far
617 checkErrsRn (RnDown {rn_errs = errs_var}) l_down
618 = readIORef errs_var >>= \ (warns,errs) ->
619 return (isEmptyBag errs)
624 \subsubsection{ Source location}
625 %=====================
628 pushSrcLocRn :: SrcLoc -> RnM d a -> RnM d a
629 pushSrcLocRn loc' m down l_down
630 = m (down {rn_loc = loc'}) l_down
632 getSrcLocRn :: RnM d SrcLoc
633 getSrcLocRn down l_down
634 = return (rn_loc down)
638 \subsubsection{ Name supply}
639 %=====================
642 getNameSupplyRn :: RnM d RnNameSupply
643 getNameSupplyRn rn_down l_down
644 = readIORef (rn_ns rn_down)
646 setNameSupplyRn :: RnNameSupply -> RnM d ()
647 setNameSupplyRn names' (RnDown {rn_ns = names_var}) l_down
648 = writeIORef names_var names'
650 -- See comments with RnNameSupply above.
651 newInstUniq :: String -> RnM d Int
652 newInstUniq key (RnDown {rn_ns = names_var}) l_down
653 = readIORef names_var >>= \ (us, mapInst, cache, ipcache) ->
655 uniq = case lookupFM mapInst key of
658 mapInst' = addToFM mapInst key uniq
660 writeIORef names_var (us, mapInst', cache, ipcache) >>
663 getUniqRn :: RnM d Unique
664 getUniqRn (RnDown {rn_ns = names_var}) l_down
665 = readIORef names_var >>= \ (us, mapInst, cache, ipcache) ->
667 (us1,us') = splitUniqSupply us
669 writeIORef names_var (us', mapInst, cache, ipcache) >>
670 return (uniqFromSupply us1)
674 \subsubsection{ Module}
675 %=====================
678 getModuleRn :: RnM d ModuleName
679 getModuleRn (RnDown {rn_mod = mod_name}) l_down
682 setModuleRn :: ModuleName -> RnM d a -> RnM d a
683 setModuleRn new_mod enclosed_thing rn_down l_down
684 = enclosed_thing (rn_down {rn_mod = new_mod}) l_down
688 %************************************************************************
690 \subsection{Plumbing for rename-source part}
692 %************************************************************************
695 \subsubsection{ RnEnv}
696 %=====================
699 getNameEnvs :: RnMS (GlobalRdrEnv, LocalRdrEnv)
700 getNameEnvs rn_down (SDown {rn_genv = global_env, rn_lenv = local_env})
701 = return (global_env, local_env)
703 getLocalNameEnv :: RnMS LocalRdrEnv
704 getLocalNameEnv rn_down (SDown {rn_lenv = local_env})
707 setLocalNameEnv :: LocalRdrEnv -> RnMS a -> RnMS a
708 setLocalNameEnv local_env' m rn_down l_down
709 = m rn_down (l_down {rn_lenv = local_env'})
711 getFixityEnv :: RnMS FixityEnv
712 getFixityEnv rn_down (SDown {rn_fixenv = fixity_env})
715 extendFixityEnv :: [(Name, RenamedFixitySig)] -> RnMS a -> RnMS a
716 extendFixityEnv fixes enclosed_scope
717 rn_down l_down@(SDown {rn_fixenv = fixity_env})
719 new_fixity_env = extendNameEnv fixity_env fixes
721 enclosed_scope rn_down (l_down {rn_fixenv = new_fixity_env})
725 \subsubsection{ Mode}
726 %=====================
729 getModeRn :: RnMS RnMode
730 getModeRn rn_down (SDown {rn_mode = mode})
733 setModeRn :: RnMode -> RnMS a -> RnMS a
734 setModeRn new_mode thing_inside rn_down l_down
735 = thing_inside rn_down (l_down {rn_mode = new_mode})
739 %************************************************************************
741 \subsection{Plumbing for rename-globals part}
743 %************************************************************************
746 getIfacesRn :: RnM d Ifaces
747 getIfacesRn (RnDown {rn_ifaces = iface_var}) _
748 = readIORef iface_var
750 setIfacesRn :: Ifaces -> RnM d ()
751 setIfacesRn ifaces (RnDown {rn_ifaces = iface_var}) _
752 = writeIORef iface_var ifaces
754 getHiMaps :: RnM d (SearchPath, ModuleHiMap, ModuleHiMap)
755 getHiMaps (RnDown {rn_hi_maps = himaps}) _