[commit: ghc] wip/nfs-locking: Dependencies: Use msum instead of explicit pattern matching (1c8539d)

git at git.haskell.org git at git.haskell.org
Thu Oct 26 23:41:59 UTC 2017


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

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

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

commit 1c8539dfd3761a3a69d9514d58e3e196127661a3
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Wed Dec 16 16:35:24 2015 +0100

    Dependencies: Use msum instead of explicit pattern matching


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

1c8539dfd3761a3a69d9514d58e3e196127661a3
 src/Oracles/Dependencies.hs | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/Oracles/Dependencies.hs b/src/Oracles/Dependencies.hs
index d0f926d..c27c2cc 100644
--- a/src/Oracles/Dependencies.hs
+++ b/src/Oracles/Dependencies.hs
@@ -2,6 +2,7 @@
 module Oracles.Dependencies (dependencies, dependenciesOracle) where
 
 import Base
+import Control.Monad.Trans.Maybe
 import qualified Data.HashMap.Strict as Map
 
 newtype DependenciesKey = DependenciesKey (FilePath, FilePath)
@@ -16,12 +17,11 @@ newtype DependenciesKey = DependenciesKey (FilePath, FilePath)
 dependencies :: FilePath -> FilePath -> Action (FilePath, [FilePath])
 dependencies path obj = do
     let depFile = path -/- ".dependencies"
-    res1 <- askOracle $ DependenciesKey (depFile, obj)
-    -- if no dependencies found attempt to drop the way prefix (for *.c sources)
-    res2 <- case res1 of
-        Nothing -> askOracle $ DependenciesKey (depFile, obj -<.> "o")
-        _       -> return res1
-    case res2 of
+    -- if no dependencies found then attempt to drop the way prefix (for *.c sources)
+    res <- runMaybeT $ msum
+           $ map (\obj' -> MaybeT $ askOracle $ DependenciesKey (depFile, obj'))
+                 [obj, obj -<.> "o"]
+    case res of
         Nothing -> putError $ "No dependencies found for '" ++ obj ++ "'."
         Just [] -> putError $ "Empty dependency list for '" ++ obj ++ "'."
         Just (src:depFiles) -> return (src, depFiles)



More information about the ghc-commits mailing list