#include "HsVersions.h"
-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 302
+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 405
+import IOExts ( fixIO )
+#elif defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 302
import PrelIOBase ( fixIO ) -- Should be in GlaExts
#else
import IOBase ( fixIO )
decode, mkLocalName
)
import Module ( Module, ModuleName, ModuleHiMap, SearchPath, WhereFrom,
- mkModuleHiMaps, moduleName
+ mkModuleHiMaps, moduleName, mkVanillaModule, mkSearchPath
)
import NameSet
import RdrName ( RdrName, dummyRdrVarName, rdrNameOcc )
-import CmdLineOpts ( opt_D_dump_rn_trace, opt_IgnoreIfacePragmas )
+import CmdLineOpts ( opt_D_dump_rn_trace, opt_HiMap )
import PrelInfo ( builtinNames )
import TysWiredIn ( boolTyCon )
import SrcLoc ( SrcLoc, mkGeneratedSrcLoc )
--------------------------------
-data ExportEnv = ExportEnv Avails Fixities
+data ExportEnv = ExportEnv Avails Fixities [ModuleName]
+ -- The list of modules is the modules exported
+ -- with 'module M' in the export list
+
type Avails = [AvailInfo]
type Fixities = [(Name, Fixity)]
-- needed by Main to fish out the fixities assoc list.
getIfaceFixities :: InterfaceDetails -> Fixities
-getIfaceFixities (_, _, ExportEnv _ fs) = fs
+getIfaceFixities (_, _, ExportEnv _ fs _) = fs
type RdrNamePragma = () -- Fudge for now
-- only do any I/O if we need to read in a fixity declaration;
-- and that doesn't happen in pragmas etc
+ mkModuleHiMaps (mkSearchPath opt_HiMap) >>= \ himaps ->
newIORef name_supply >>= \ names_var ->
newIORef (emptyBag,emptyBag) >>= \ errs_var ->
let
rn_down = RnDown { rn_loc = mkGeneratedSrcLoc, rn_ns = names_var,
- rn_errs = errs_var,
- rn_mod = mod_name }
+ rn_errs = errs_var, rn_hi_maps = himaps,
+ rn_mod = mod_name,
+ rn_ifaces = panic "rnameSourceCode: rn_ifaces" -- Not required
+ }
s_down = SDown { rn_mode = InterfaceMode,
-- So that we can refer to PrelBase.True etc
rn_genv = emptyRdrEnv, rn_lenv = emptyRdrEnv,
mapRn :: (a -> RnM d b) -> [a] -> RnM d [b]
mapRn_ :: (a -> RnM d b) -> [a] -> RnM d ()
mapMaybeRn :: (a -> RnM d (Maybe b)) -> [a] -> RnM d [b]
+flatMapRn :: (a -> RnM d [b]) -> [a] -> RnM d [b]
sequenceRn :: [RnM d a] -> RnM d [a]
foldlRn :: (b -> a -> RnM d b) -> b -> [a] -> RnM d b
mapAndUnzipRn :: (a -> RnM d (b,c)) -> [a] -> RnM d ([b],[c])
case maybe_r of
Nothing -> returnRn rs
Just r -> returnRn (r:rs)
+
+flatMapRn f [] = returnRn []
+flatMapRn f (x:xs) = f x `thenRn` \ r ->
+ flatMapRn f xs `thenRn` \ rs ->
+ returnRn (r ++ rs)
\end{code}
getHiMaps (RnDown {rn_hi_maps = himaps}) _
= return himaps
\end{code}
+
+\begin{code}
+lookupModuleRn :: ModuleName -> RnM d Module
+lookupModuleRn x =
+ getHiMaps `thenRn` \ (himap, _) ->
+ case lookupFM himap x of
+ Nothing -> returnRn (mkVanillaModule x)
+ Just (_,x) -> returnRn x
+
+\end{code}