[project @ 2004-01-09 12:36:54 by simonmar]
[ghc-hetmet.git] / ghc / compiler / basicTypes / Module.lhs
index c00b8ee..ea4de1e 100644 (file)
@@ -56,8 +56,8 @@ module Module
     , moduleString             -- :: Module -> EncodedString
     , moduleUserString         -- :: Module -> UserString
 
+    , mkModule
     , mkBasePkgModule          -- :: UserString -> Module
-    , mkThPkgModule            -- :: UserString -> Module
     , mkHomeModule             -- :: ModuleName -> Module
     , isHomeModule             -- :: Module -> Bool
     , mkPackageModule          -- :: ModuleName -> Module
@@ -83,9 +83,8 @@ module Module
 #include "HsVersions.h"
 import OccName
 import Outputable
-import Packages                ( PackageName, basePackage, thPackage )
+import Packages                ( PackageName, basePackage )
 import CmdLineOpts     ( opt_InPackage )
-import FastString      ( FastString )
 import Unique          ( Uniquable(..) )
 import Maybes          ( expectJust )
 import UniqFM
@@ -142,9 +141,17 @@ instance Outputable PackageInfo where
 data ModLocation
    = ModLocation {
         ml_hs_file   :: Maybe FilePath,
-        ml_hspp_file :: Maybe FilePath,  -- path of preprocessed source
-        ml_hi_file   :: FilePath,
-        ml_obj_file  :: Maybe FilePath
+
+        ml_hspp_file :: Maybe FilePath, -- Path of preprocessed source
+
+        ml_hi_file   :: FilePath,      -- Where the .hi file is, whether or not it exists
+                                       -- Always of form foo.hi, even if there is an hi-boot
+                                       -- file (we add the -boot suffix later)
+
+        ml_obj_file  :: FilePath       -- Where the .o file is, whether or not it exists
+                                       -- (might not exist either because the module
+                                       --  hasn't been compiled yet, or because
+                                       --  it is part of a package with a .a file)
      }
      deriving Show
 
@@ -158,7 +165,7 @@ showModMsg use_object mod location =
     mod_str ++ replicate (max 0 (16 - length mod_str)) ' '
     ++" ( " ++ expectJust "showModMsg" (ml_hs_file location) ++ ", "
     ++ (if use_object
-         then expectJust "showModMsg" (ml_obj_file location)
+         then ml_obj_file location
          else "interpreted")
     ++ " )"
  where mod_str = moduleUserString mod
@@ -262,21 +269,16 @@ pprModule (Module mod p) = getPprStyle $ \ sty ->
 
 
 \begin{code}
-mkBasePkgModule :: ModuleName -> Module
-mkBasePkgModule mod_nm
-  = Module mod_nm pack_info
+mkModule :: PackageName -> ModuleName -> Module
+mkModule pkg_name mod_name 
+  = Module mod_name pkg_info
   where
-    pack_info
-      | opt_InPackage == basePackage = ThisPackage
-      | otherwise                   = AnotherPackage
+    pkg_info
+      | opt_InPackage == pkg_name = ThisPackage
+      | otherwise                = AnotherPackage
 
-mkThPkgModule :: ModuleName -> Module
-mkThPkgModule mod_nm
-  = Module mod_nm pack_info
-  where
-    pack_info
-      | opt_InPackage == thPackage = ThisPackage
-      | otherwise                 = AnotherPackage
+mkBasePkgModule :: ModuleName -> Module
+mkBasePkgModule mod_nm = mkModule basePackage mod_nm
 
 mkHomeModule :: ModuleName -> Module
 mkHomeModule mod_nm = Module mod_nm ThisPackage