diff options
author | Daniel Gröber <dxld@darkboxed.org> | 2018-10-12 00:41:38 +0200 |
---|---|---|
committer | Daniel Gröber <dxld@darkboxed.org> | 2018-10-26 04:33:07 +0200 |
commit | fbbb3590c7f6eca69a5c77a5215c29363595cd0d (patch) | |
tree | 5ba24da49a6579fdb4dd3f28459f75bf9f9931c9 /src/CabalHelper/Shared | |
parent | e6d50e71f0b11377c3839eee52ca08345bce7e8a (diff) |
Move 'mightExist' to Common module
Diffstat (limited to 'src/CabalHelper/Shared')
-rw-r--r-- | src/CabalHelper/Shared/Common.hs | 5 | ||||
-rw-r--r-- | src/CabalHelper/Shared/Sandbox.hs | 9 |
2 files changed, 7 insertions, 7 deletions
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) [] |