aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CabalHelper/Compiletime/Compile.hs22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/CabalHelper/Compiletime/Compile.hs b/src/CabalHelper/Compiletime/Compile.hs
index 431043b..6403aca 100644
--- a/src/CabalHelper/Compiletime/Compile.hs
+++ b/src/CabalHelper/Compiletime/Compile.hs
@@ -681,18 +681,16 @@ errorInstallCabal cabalVer = panicIO $ printf "\
listCabalVersions' :: Env => Maybe PackageDbDir -> MaybeT IO [Version]
listCabalVersions' mdb = do
- case mdb of
- Nothing -> mzero
- Just (PackageDbDir db_path) -> do
- exists <- liftIO $ doesDirectoryExist db_path
- case exists of
- False -> mzero
- True -> MaybeT $ logIOError "listCabalVersions'" $ Just <$> do
- let mdbopt = ("--package-conf="++) <$> unPackageDbDir <$> mdb
- args = ["list", "--simple-output", "Cabal"] ++ maybeToList mdbopt
-
- catMaybes . map (fmap snd . parsePkgId . fromString) . words
- <$> readProcess' (ghcProgram ?cprogs) args ""
+ let mdb_path = unPackageDbDir <$> mdb
+ exists <- fromMaybe True <$>
+ traverse (liftIO . doesDirectoryExist) mdb_path
+ case exists of
+ True -> MaybeT $ logIOError "listCabalVersions" $ Just <$> do
+ let mdbopt = ("--package-conf="++) <$> mdb_path
+ args = ["list", "--simple-output", "Cabal"] ++ maybeToList mdbopt
+ catMaybes . map (fmap snd . parsePkgId . fromString) . words
+ <$> readProcess' (ghcPkgProgram ?cprogs) args ""
+ _ -> mzero
cabalVersionExistsInPkgDb :: Env => Version -> PackageDbDir -> IO Bool
cabalVersionExistsInPkgDb cabalVer db@(PackageDbDir db_path) = do