[commit: Cabal] master: Do not add lower case .hs files as modules in cabal init (4ae50a3)
Ian Lynagh
igloo at earth.li
Fri Jun 24 02:06:42 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/Cabal
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/4ae50a3d95e5205152bcf26308d4f098c864ab26
>---------------------------------------------------------------
commit 4ae50a3d95e5205152bcf26308d4f098c864ab26
Author: Duncan Coutts <duncan at haskell.org>
Date: Mon Jun 14 21:35:36 2010 +0000
Do not add lower case .hs files as modules in cabal init
There's still something wrong with the recursive dir traversal.
It fails in some large cases.
>---------------------------------------------------------------
.../Distribution/Client/Init/Heuristics.hs | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/cabal-install/Distribution/Client/Init/Heuristics.hs b/cabal-install/Distribution/Client/Init/Heuristics.hs
index 82f4745..19ec668 100644
--- a/cabal-install/Distribution/Client/Init/Heuristics.hs
+++ b/cabal-install/Distribution/Client/Init/Heuristics.hs
@@ -66,7 +66,9 @@ scanForModulesIn projectRoot srcRoot = scan srcRoot []
scan dir hierarchy = do
entries <- getDirectoryContents (projectRoot </> dir)
(files, dirs) <- liftM partitionEithers (mapM (tagIsDir dir) entries)
- let modules = catMaybes [ guessModuleName hierarchy file | file <- files ]
+ let modules = catMaybes [ guessModuleName hierarchy file
+ | file <- files
+ , isUpper (head file) ]
recMods <- mapM (scanRecursive dir hierarchy) dirs
return $ concat (modules : recMods)
tagIsDir parent entry = do
@@ -83,9 +85,11 @@ scanForModulesIn projectRoot srcRoot = scan srcRoot []
ext = case takeExtension entry of '.':e -> e; e -> e
scanRecursive parent hierarchy entry
| isUpper (head entry) = scan (parent </> entry) (entry : hierarchy)
- | isLower (head entry) && entry /= "dist" =
+ | isLower (head entry) && not (ignoreDir entry) =
scanForModulesIn projectRoot $ foldl (</>) srcRoot (entry : hierarchy)
| otherwise = return []
+ ignoreDir ('.':_) = True
+ ignoreDir dir = dir `elem` ["dist", "_darcs"]
-- Unfortunately we cannot use the version exported by Distribution.Simple.Program
knownSuffixHandlers :: [(String,String)]
More information about the Cvs-libraries
mailing list