[commit: ghc] wip/nfs-locking: Refactor Oracles.hs. (e20c4bc)

git at git.haskell.org git at git.haskell.org
Thu Oct 26 23:45:43 UTC 2017


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

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

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

commit e20c4bc3bec68971837c2808724edbfcbe0b92ab
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Tue Dec 30 15:12:40 2014 +0000

    Refactor Oracles.hs.


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

e20c4bc3bec68971837c2808724edbfcbe0b92ab
 src/Oracles.hs | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/Oracles.hs b/src/Oracles.hs
index 98321c9..75439fb 100644
--- a/src/Oracles.hs
+++ b/src/Oracles.hs
@@ -246,14 +246,11 @@ askConfigWithDefault key defaultAction = do
     maybeValue <- askOracle $ ConfigKey key 
     case maybeValue of
         Just value -> return value
-        Nothing    -> do
-                        result <- defaultAction
-                        return result
+        Nothing    -> defaultAction
 
 askConfig :: String -> Action String
-askConfig key = askConfigWithDefault key $ error $ "\nCannot find key '"
-                                         ++ key
-                                         ++ "' in configuration files."
+askConfig key = askConfigWithDefault key $
+    error $ "\nCannot find key '" ++ key ++ "' in configuration files."
 
 newtype PackageDataPair = PackageDataPair (FilePath, String)
                         deriving (Show, Typeable, Eq, Hashable, Binary, NFData)
@@ -263,9 +260,7 @@ packagaDataOptionWithDefault file key defaultAction = do
     maybeValue <- askOracle $ PackageDataPair (file, key) 
     case maybeValue of
         Just value -> return value
-        Nothing    -> do
-                        result <- defaultAction
-                        return result   -- TODO: simplify
+        Nothing    -> defaultAction
 
 data PackageDataKey = Modules | SrcDirs
 
@@ -274,12 +269,8 @@ packagaDataOption file key = do
     let keyName = replaceIf isSlash '_' $ takeDirectory file ++ case key of
            Modules -> "_MODULES"
            SrcDirs -> "_HS_SRC_DIRS"
-    packagaDataOptionWithDefault file keyName $ error $ "\nCannot find key '"
-                                         ++ keyName
-                                         ++ "' in "
-                                         ++ file
-                                         ++ "." -- TODO: Improve formatting
-
+    packagaDataOptionWithDefault file keyName $
+        error $ "\nCannot find key '" ++ keyName ++ "' in " ++ file ++ "."
 
 oracleRules :: Rules ()
 oracleRules = do



More information about the ghc-commits mailing list