[commit: ghc] wip/nfs-locking: Add findModuleFiles and export it. (9039a4f)

git at git.haskell.org git at git.haskell.org
Fri Oct 27 00:05:01 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/nfs-locking
Link       : http://ghc.haskell.org/trac/ghc/changeset/9039a4f1dfedbc9606d2ccef35d81d7736993f11/ghc

>---------------------------------------------------------------

commit 9039a4f1dfedbc9606d2ccef35d81d7736993f11
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Sun Feb 21 02:21:00 2016 +0000

    Add findModuleFiles and export it.
    
    See #210.


>---------------------------------------------------------------

9039a4f1dfedbc9606d2ccef35d81d7736993f11
 src/Oracles/ModuleFiles.hs | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/Oracles/ModuleFiles.hs b/src/Oracles/ModuleFiles.hs
index bced848..501bc89 100644
--- a/src/Oracles/ModuleFiles.hs
+++ b/src/Oracles/ModuleFiles.hs
@@ -1,5 +1,7 @@
 {-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving, ScopedTypeVariables #-}
-module Oracles.ModuleFiles (moduleFiles, haskellModuleFiles, moduleFilesOracle) where
+module Oracles.ModuleFiles (
+    moduleFiles, haskellModuleFiles, moduleFilesOracle, findModuleFiles
+    ) where
 
 import Base
 import Context
@@ -16,7 +18,7 @@ moduleFiles context @ (Context {..}) = do
     srcDirs <- fmap sort . pkgDataList $ SrcDirs path
     modules <- fmap sort . pkgDataList $ Modules path
     let dirs = [ pkgPath package -/- dir | dir <- srcDirs ]
-    fmap catMaybes . askOracle $ ModuleFilesKey (dirs, modules)
+    fmap catMaybes $ findModuleFiles dirs modules
 
 haskellModuleFiles :: Context -> Action ([FilePath], [String])
 haskellModuleFiles context @ (Context {..}) = do
@@ -26,8 +28,8 @@ haskellModuleFiles context @ (Context {..}) = do
     srcDirs <- fmap sort . pkgDataList $ SrcDirs path
     modules <- fmap sort . pkgDataList $ Modules path
     let dirs = [ pkgPath package -/- dir | dir <- srcDirs ]
-    foundSrcDirs <- askOracle $ ModuleFilesKey (dirs     , modules)
-    foundAutogen <- askOracle $ ModuleFilesKey ([autogen], modules)
+    foundSrcDirs <- findModuleFiles dirs      modules
+    foundAutogen <- findModuleFiles [autogen] modules
     found <- sequence $ zipWith3 addSources modules foundSrcDirs foundAutogen
 
     let missingMods    = map fst . filter (isNothing . snd) $ zip modules found
@@ -43,13 +45,17 @@ haskellModuleFiles context @ (Context {..}) = do
 -- | This is an important oracle whose role is to find and cache module source
 -- files. More specifically, it takes a list of directories @dirs@ and a sorted
 -- list of module names @modules@ as arguments, and for each module, e.g.
--- @A.B.C@, returns a FilePath of the form @dir/A/B/C.extension@, such that
--- @dir@ belongs to @dirs@, and file @dir/A/B/C.extension@ exists, or Nothing
+-- @A.B.C@, returns a 'FilePath' of the form @dir/A/B/C.extension@, such that
+-- @dir@ belongs to @dirs@, and file @dir/A/B/C.extension@ exists, or 'Nothing'
 -- if there is no such file. If more than one matching file is found an error is
 -- raised. For example, for the 'compiler' package given
--- @dirs = ["codeGen", "parser"]@, and
+-- @dirs = ["compiler/codeGen", "compiler/parser"]@, and
 -- @modules = ["CodeGen.Platform.ARM", "Lexer", "Missing.Module"]@, it produces
--- @[Just "codeGen/CodeGen/Platform/ARM.hs", Just "parser/Lexer.x", Nothing]@.
+-- @[Just "compiler/codeGen/CodeGen/Platform/ARM.hs",
+-- Just "compiler/parser/Lexer.x", Nothing]@.
+findModuleFiles :: [FilePath] -> [String] -> Action [Maybe FilePath]
+findModuleFiles dirs modules = askOracle $ ModuleFilesKey (dirs, modules)
+
 moduleFilesOracle :: Rules ()
 moduleFilesOracle = void $
     addOracle $ \(ModuleFilesKey (dirs, modules)) -> do



More information about the ghc-commits mailing list