diff --git a/src/Path/Extended.hs b/src/Path/Extended.hs index e6e82ac718..02f5950a7b 100644 --- a/src/Path/Extended.hs +++ b/src/Path/Extended.hs @@ -2,15 +2,40 @@ module Path.Extended ( fileExtension + , addExtension + , replaceExtension ) where import Control.Monad.Catch -import qualified Path as Path +import qualified Path +import Path (Path, File) -fileExtension :: MonadThrow m => Path.Path b Path.File -> m String +fileExtension :: MonadThrow m => Path b File -> m String fileExtension = #if MIN_VERSION_path(0,7,0) Path.fileExtension #else pure . Path.fileExtension #endif + +addExtension :: MonadThrow m + => String + -> Path b File + -> m (Path b File) +addExtension = +#if MIN_VERSION_path(0,7,0) + Path.addExtension +#else + Path.addFileExtension +#endif + +replaceExtension :: MonadThrow m + => String + -> Path b File + -> m (Path b File) +replaceExtension = +#if MIN_VERSION_path(0,7,0) + Path.replaceExtension +#else + flip (Path.-<.>) +#endif diff --git a/src/Stack/Coverage.hs b/src/Stack/Coverage.hs index 0de1ec8613..ede8bc20cc 100644 --- a/src/Stack/Coverage.hs +++ b/src/Stack/Coverage.hs @@ -46,7 +46,7 @@ import RIO.Process import Trace.Hpc.Tix import Web.Browser (openBrowser) -data CoverageException = NonTestSuiteTarget PackageName deriving Typeable +newtype CoverageException = NonTestSuiteTarget PackageName deriving Typeable instance Exception CoverageException instance Show CoverageException where diff --git a/src/Stack/Docker.hs b/src/Stack/Docker.hs index bced11d6c9..0f721fbe83 100644 --- a/src/Stack/Docker.hs +++ b/src/Stack/Docker.hs @@ -41,7 +41,12 @@ import qualified Data.Text.Encoding as T import Data.Time (UTCTime) import Data.Version (showVersion) import Distribution.Version (mkVersion) +#if MIN_VERSION_path(0,7,0) +import Path hiding (replaceExtension) +#else import Path +#endif +import Path.Extended (replaceExtension) import Path.Extra (toFilePathNoTrailingSep) import Path.IO hiding (canonicalizePath) import qualified Paths_stack as Meta @@ -150,7 +155,7 @@ getCmdArgs docker imageInfo isRemoteDocker = do exePath <- ensureDockerStackExe dockerContainerPlatform cmdArgs args exePath cmdArgs args exePath = do - exeBase <- exePath -<.> "" + exeBase <- replaceExtension "" exePath let mountPath = hostBinDir FP. toFilePath (filename exeBase) return (mountPath, args, [], [Mount (toFilePath exePath) mountPath]) diff --git a/src/Stack/Lock.hs b/src/Stack/Lock.hs index fa1ff73a23..642fb804f8 100644 --- a/src/Stack/Lock.hs +++ b/src/Stack/Lock.hs @@ -16,7 +16,8 @@ import qualified Data.List.NonEmpty as NE import qualified Data.Map as Map import qualified Data.Yaml as Yaml import Pantry -import Path (addFileExtension, parent) +import Path (parent) +import Path.Extended (addExtension) import Path.IO (doesFileExist) import Stack.Prelude import Stack.SourceMap @@ -94,7 +95,7 @@ lockCachedWanted :: -> RIO env ( SMWanted, [CompletedPLI])) -> RIO env SMWanted lockCachedWanted stackFile resolver fillWanted = do - lockFile <- liftIO $ addFileExtension "lock" stackFile + lockFile <- liftIO $ addExtension ".lock" stackFile let getLockExists = doesFileExist lockFile lfb <- view lockFileBehaviorL readLockFile <-