[project @ 2001-03-23 16:36:20 by simonmar]
[ghc-hetmet.git] / ghc / compiler / main / Finder.lhs
index 03c2bbe..4e4844d 100644 (file)
@@ -5,7 +5,7 @@
 
 \begin{code}
 module Finder (
-    initFinder,        -- :: PackageConfigInfo -> IO (), 
+    initFinder,        -- :: [PackageConfig] -> IO (), 
     findModule,                -- :: ModuleName -> IO (Maybe (Module, ModuleLocation))
     mkHomeModuleLocn,  -- :: ModuleName -> String -> FilePath 
                        --      -> IO ModuleLocation
@@ -30,7 +30,7 @@ import Directory
 import List
 import IO
 import Monad
-import Outputable      ( showSDoc, ppr )       -- debugging only
+import Outputable
 \end{code}
 
 The Finder provides a thin filesystem abstraction to the rest of the
@@ -49,7 +49,7 @@ GLOBAL_VAR(v_PkgDirCache, panic "no pkg cache!",
 GLOBAL_VAR(v_HomeDirCache, Nothing, Maybe (FiniteMap String FilePath))
 
 
-initFinder :: PackageConfigInfo -> IO ()
+initFinder :: [PackageConfig] -> IO ()
 initFinder pkgs 
   = do {       -- expunge our home cache
        ; writeIORef v_HomeDirCache Nothing
@@ -95,11 +95,15 @@ maybeHomeModule mod_name = do
        lhs = basename ++ ".lhs"
 
    case lookupFM home_map hs of {
+         -- special case to avoid getting "./foo.hs" all the time
+       Just "."  -> mkHomeModuleLocn mod_name basename hs;
        Just path -> mkHomeModuleLocn mod_name 
                        (path ++ '/':basename) (path ++ '/':hs);
        Nothing ->
 
    case lookupFM home_map lhs of {
+         -- special case to avoid getting "./foo.hs" all the time
+       Just "."  -> mkHomeModuleLocn mod_name basename lhs;
        Just path ->  mkHomeModuleLocn mod_name
                        (path ++ '/':basename) (path ++ '/':lhs);
        Nothing -> do
@@ -156,15 +160,14 @@ mkHomeModuleLocn mod_name basename source_fn = do
        ))
 
 
-newPkgCache :: [Package] -> IO (FiniteMap String (PackageName, FilePath))
+newPkgCache :: [PackageConfig] -> IO (FiniteMap String (PackageName, FilePath))
 newPkgCache pkgs = do
     let extendFM fm pkg = do
            let dirs = import_dirs pkg
                pkg_name = _PK_ (name pkg)
            let addDir fm dir = do
                    contents <- getDirectoryContents' dir
-                   let clean_contents = filter isUsefulFile contents
-                   return (addListToFM fm (zip clean_contents 
+                   return (addListToFM fm (zip contents 
                                               (repeat (pkg_name,dir))))
            foldM addDir fm dirs
     
@@ -208,5 +211,5 @@ getDirectoryContents' d
                          ("WARNING: error while reading directory " ++ d)
                    return []
          )
-        
+
 \end{code}