[project @ 2001-07-24 04:47:06 by ken]
[ghc-hetmet.git] / ghc / compiler / main / Finder.lhs
index 2fc393d..74b243a 100644 (file)
@@ -7,6 +7,7 @@
 module Finder (
     initFinder,        -- :: [PackageConfig] -> IO (), 
     findModule,                -- :: ModuleName -> IO (Maybe (Module, ModuleLocation))
+    findPackageModule, -- :: ModuleName -> IO (Maybe (Module, ModuleLocation))
     mkHomeModuleLocn,  -- :: ModuleName -> String -> Maybe FilePath 
                        --      -> IO ModuleLocation
     emptyHomeDirCache, -- :: IO ()
@@ -52,7 +53,7 @@ findModule name
   = do { j <- maybeHomeModule name
        ; case j of
            Just home_module -> return (Just home_module)
-           Nothing          -> maybePackageModule name
+           Nothing          -> findPackageModule name
        }
 
 maybeHomeModule :: ModuleName -> IO (Maybe (Module, ModuleLocation))
@@ -139,8 +140,8 @@ mkHomeModuleLocn mod_name basename maybe_source_fn = do
        ))
 
 
-maybePackageModule :: ModuleName -> IO (Maybe (Module, ModuleLocation))
-maybePackageModule mod_name = do
+findPackageModule :: ModuleName -> IO (Maybe (Module, ModuleLocation))
+findPackageModule mod_name = do
   pkgs <- getPackageInfo
 
   -- hi-suffix for packages depends on the build tag.
@@ -150,7 +151,8 @@ maybePackageModule mod_name = do
                then return "hi"
                else return (tag ++ "_hi")
 
-  let basename = moduleNameUserString mod_name
+  let mod_str  = moduleNameUserString mod_name 
+      basename = map (\c -> if c == '.' then '/' else c) mod_str
       hi = basename ++ '.':package_hisuf
 
   found <- findOnPackagePath pkgs hi
@@ -161,7 +163,7 @@ maybePackageModule mod_name = do
                          ModuleLocation{ 
                                 ml_hspp_file = Nothing,
                                ml_hs_file   = Nothing,
-                               ml_hi_file   = path,
+                               ml_hi_file   = path ++ '/':hi,
                                ml_obj_file  = Nothing
                           }
                   ))
@@ -175,7 +177,7 @@ findOnPackagePath pkgs file = loop pkgs
     found <- findOnPath (import_dirs p) file
     case found of
        Nothing   -> loop ps
-       Just path -> return (Just (mkFastString (name p), path ++ '/':file))
+       Just path -> return (Just (mkFastString (name p), path))
 
 findOnPath :: [String] -> String -> IO (Maybe FilePath)
 findOnPath path s = loop path