Commit 7fcc1afe authored by Michael Hanus 's avatar Michael Hanus

Search for hierchical modules added

parent 8b2b2fba
......@@ -7,7 +7,7 @@ module CPM.Main where
import CSV (showCSV)
import Directory (doesFileExist, getAbsolutePath, doesDirectoryExist
, createDirectory, getDirectoryContents)
import Distribution (installDir)
import Distribution (installDir, stripCurrySuffix)
import Either
import FilePath ((</>), takeExtension)
import IO (hFlush, stdout)
......@@ -547,7 +547,7 @@ check opts cfg repo gc =
tryFindLocalPackageSpec "." |>=
\specDir -> loadPackageSpec specDir |>=
\localSpec -> do
mainprogs <- curryFilesInDir (specDir </> "src")
mainprogs <- curryModulesInDir (specDir </> "src")
let (showexp,showmods) = modules localSpec mainprogs
if null showmods
then putStrLn "No modules to be checked!" >> succeedIO ()
......@@ -563,10 +563,20 @@ check opts cfg repo gc =
else ("exported ", intercalate " " exports)
Just ms -> ("", intercalate " " ms)
curryFilesInDir d = do
--- Geet the names of all Curry modules containing in a directory.
--- Modules in subdirectories are returned as hierarchical modules.
curryModulesInDir :: String -> IO [String]
curryModulesInDir dir = getModules "" dir
where
getModules p d = do
entries <- getDirectoryContents d
return $ filter (\f -> length f >= 1 && head f /= '.' &&
takeExtension f == ".curry") entries
let realentries = filter (\f -> length f >= 1 && head f /= '.') entries
newprogs = filter (\f -> takeExtension f == ".curry") realentries
subdirs <- mapIO (\e -> doesDirectoryExist (d </> e) >>=
\b -> return $ if b then [e] else []) realentries
>>= return . concat
subdirentries <- mapIO (\s -> getModules (p ++ s ++ ".") (d </> s)) subdirs
return $ map ((p ++) . stripCurrySuffix) newprogs ++ concat subdirentries
diff :: DiffOptions -> Config -> Repository -> GlobalCache
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment