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 ()
#include "HsVersions.h"
import HscTypes ( ModuleLocation(..) )
-import CmStaticInfo
+import Packages ( PackageConfig(..) )
import DriverPhases
import DriverState
-import DriverUtil
import Module
-import FiniteMap
import FastString
-import Util
-import Panic ( panic )
import Config
import IOExts
= 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))
))
-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.
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
case found of
Nothing -> return Nothing
- Just (pkg_name,path) ->
+ Just (pkg_name,path) ->
return (Just (mkModule mod_name pkg_name,
ModuleLocation{
ml_hspp_file = Nothing,
ml_hs_file = Nothing,
- ml_hi_file = path,
+ ml_hi_file = path ++ '/':hi,
ml_obj_file = Nothing
}
))
loop (p:ps) = do
found <- findOnPath (import_dirs p) file
case found of
- Nothing -> loop ps
- Just f -> return (Just (mkFastString (name p), f))
+ Nothing -> loop ps
+ Just path -> return (Just (mkFastString (name p), path))
findOnPath :: [String] -> String -> IO (Maybe FilePath)
findOnPath path s = loop path