From fbbb3590c7f6eca69a5c77a5215c29363595cd0d Mon Sep 17 00:00:00 2001 From: Daniel Gröber Date: Fri, 12 Oct 2018 00:41:38 +0200 Subject: Move 'mightExist' to Common module --- src/CabalHelper/Shared/Common.hs | 5 +++++ src/CabalHelper/Shared/Sandbox.hs | 9 ++------- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/CabalHelper/Shared/Common.hs b/src/CabalHelper/Shared/Common.hs index 8e8418b..d60e745 100644 --- a/src/CabalHelper/Shared/Common.hs +++ b/src/CabalHelper/Shared/Common.hs @@ -162,3 +162,8 @@ readPackageDescription = P.readGenericPackageDescription #else readPackageDescription = P.readPackageDescription #endif + +mightExist :: FilePath -> IO (Maybe FilePath) +mightExist f = do + exists <- doesFileExist f + return $ if exists then (Just f) else (Nothing) diff --git a/src/CabalHelper/Shared/Sandbox.hs b/src/CabalHelper/Shared/Sandbox.hs index f7b7470..d2172a2 100644 --- a/src/CabalHelper/Shared/Sandbox.hs +++ b/src/CabalHelper/Shared/Sandbox.hs @@ -28,11 +28,12 @@ import Data.Maybe import Data.List import Data.Version import System.FilePath -import System.Directory import Prelude import qualified Data.Traversable as T +import CabalHelper.Shared.Common + -- | Get the path to the sandbox package-db in a project getSandboxPkgDb :: String -- ^ Cabal build platform, i.e. @buildPlatform@ @@ -68,12 +69,6 @@ extractSandboxDbDir conf = extractValue <$> parse conf parse = listToMaybe . filter (key `isPrefixOf`) . lines extractValue = CabalHelper.Shared.Sandbox.dropWhileEnd isSpace . dropWhile isSpace . drop keyLen - -mightExist :: FilePath -> IO (Maybe FilePath) -mightExist f = do - exists <- doesFileExist f - return $ if exists then (Just f) else (Nothing) - -- dropWhileEnd is not provided prior to base 4.5.0.0. dropWhileEnd :: (a -> Bool) -> [a] -> [a] dropWhileEnd p = foldr (\x xs -> if p x && null xs then [] else x : xs) [] -- cgit v1.2.3