[commit: ghc] master: Simplify oracles (#694) (021e753)

git at git.haskell.org git at git.haskell.org
Tue Oct 23 20:20:49 UTC 2018


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/021e753b499d87fd2a6d34eb502ed3abac5b3791/ghc

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

commit 021e753b499d87fd2a6d34eb502ed3abac5b3791
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Sun Sep 30 12:46:37 2018 +0100

    Simplify oracles (#694)
    
    As discussed in #550, we can remove some unnecessary occurrences of `newCache`.


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

021e753b499d87fd2a6d34eb502ed3abac5b3791
 src/Hadrian/Oracles/Cabal/Rules.hs |  9 +++------
 src/Hadrian/Oracles/TextFile.hs    | 10 ----------
 2 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/src/Hadrian/Oracles/Cabal/Rules.hs b/src/Hadrian/Oracles/Cabal/Rules.hs
index a069c73..dcda370 100644
--- a/src/Hadrian/Oracles/Cabal/Rules.hs
+++ b/src/Hadrian/Oracles/Cabal/Rules.hs
@@ -36,21 +36,19 @@ import Hadrian.Utilities
 -- 3) 'Hadrian.Oracles.Cabal.configurePackageGHC' that configures a package.
 cabalOracle :: Rules ()
 cabalOracle = do
-    packageData <- newCache $ \package -> do
+    void $ addOracleCache $ \(PackageDataKey package) -> do
         let file = pkgCabalFile package
         need [file]
         putLoud $ "| PackageData oracle: parsing " ++ quote file ++ "..."
         parsePackageData package
-    void $ addOracleCache $ \(PackageDataKey package) -> packageData package
 
-    contextData <- newCache $ \(context at Context {..}) -> do
+    void $ addOracleCache $ \(ContextDataKey context at Context {..}) -> do
         putLoud $ "| ContextData oracle: resolving data for "
                ++ quote (pkgName package) ++ " (" ++ show stage
                ++ ", " ++ show way ++ ")..."
         resolveContextData context
-    void $ addOracleCache $ \(ContextDataKey context) -> contextData context
 
-    conf <- newCache $ \(pkg, stage) -> do
+    void $ addOracleCache $ \(PackageConfigurationKey (pkg, stage)) -> do
         putLoud $ "| PackageConfiguration oracle: configuring "
                ++ quote (pkgName pkg) ++ " (" ++ show stage ++ ")..."
         -- Configure the package with the GHC corresponding to the given stage
@@ -60,4 +58,3 @@ cabalOracle = do
         let platform = fromMaybe (error msg) maybePlatform
             msg      = "PackageConfiguration oracle: cannot detect platform"
         return $ PackageConfiguration (compiler, platform)
-    void $ addOracleCache $ \(PackageConfigurationKey pkgStage) -> conf pkgStage
diff --git a/src/Hadrian/Oracles/TextFile.hs b/src/Hadrian/Oracles/TextFile.hs
index 08670c0..aef553f 100644
--- a/src/Hadrian/Oracles/TextFile.hs
+++ b/src/Hadrian/Oracles/TextFile.hs
@@ -66,10 +66,6 @@ lookupDependencies depFile file = do
         Just [] -> error $ "No source file found for file " ++ quote file
         Just (source : files) -> return (source, files)
 
-newtype TextFile = TextFile FilePath
-    deriving (Binary, Eq, Hashable, NFData, Show, Typeable)
-type instance RuleResult TextFile = String
-
 newtype KeyValue = KeyValue (FilePath, String)
     deriving (Binary, Eq, Hashable, NFData, Show, Typeable)
 type instance RuleResult KeyValue = Maybe String
@@ -90,12 +86,6 @@ type instance RuleResult KeyValues = Maybe [String]
 --    see 'lookupDependencies'.
 textFileOracle :: Rules ()
 textFileOracle = do
-    text <- newCache $ \file -> do
-        need [file]
-        putLoud $ "| TextFile oracle: reading " ++ quote file ++ "..."
-        liftIO $ readFile file
-    void $ addOracleCache $ \(TextFile file) -> text file
-
     kv <- newCache $ \file -> do
         need [file]
         putLoud $ "| KeyValue oracle: reading " ++ quote file ++ "..."



More information about the ghc-commits mailing list