@@ -14,6 +14,7 @@ import Data.Yaml (decodeFileEither)
1414import System.Console.ANSI
1515import System.Directory
1616import System.Environment (lookupEnv )
17+ import System.FilePath (takeDirectory , takeFileName , (</>) )
1718import System.IO
1819
1920import DirectoryUtils
@@ -44,7 +45,7 @@ haskellingsVersion :: String
4445haskellingsVersion = " 0.8.0.0"
4546
4647mainProjectExercisesDir :: String
47- mainProjectExercisesDir = makeRelative " exercises"
48+ mainProjectExercisesDir = " exercises"
4849
4950-- A listing of packages required by exercises, so we can use them
5051-- to filter Stack snapshots
@@ -151,12 +152,12 @@ loadBaseConfigPaths :: IO (Either ConfigError (FilePath, FilePath, FilePath))
151152loadBaseConfigPaths = do
152153 projectRoot' <- findProjectRoot
153154 case projectRoot' of
154- Nothing -> return (Left NoProjectRootError )
155+ Nothing -> return (Left NoProjectRootError )
155156 Just projectRoot -> loadBaseConfigPathsWithProjectRoot projectRoot
156157
157158loadBaseConfigPathsWithProjectRoot :: FilePath -> IO (Either ConfigError (FilePath , FilePath , FilePath ))
158159loadBaseConfigPathsWithProjectRoot projectRoot = do
159- let configPath = projectRoot `pathJoin` configFileName
160+ let configPath = projectRoot </> configFileName
160161 configExists <- doesFileExist configPath
161162 baseConfig <- if configExists
162163 then do
@@ -185,17 +186,17 @@ findGhc = do
185186 Just ghcSearchDir -> do
186187 nextDirs <- listDirectory ghcSearchDir
187188 results <- forM nextDirs $ \ subPath -> do
188- let fullPath = ghcSearchDir `pathJoin` subPath
189+ let fullPath = ghcSearchDir </> subPath
189190 subContents <- safeListDirectory fullPath
190- return $ fmap (pathJoin fullPath) (find ghcPred subContents)
191+ return $ fmap (fullPath </> ) (find ghcPred subContents)
191192 case catMaybes results of
192193 [] -> return Nothing
193- (fp : _) -> return $ Just (fp `pathJoin` " bin" `pathJoin` " ghc" )
194+ (fp : _) -> return $ Just (fp </> " bin" </> " ghc" )
194195
195196-- Determine a directory is a valid "ghc" directory.
196197-- It must start with "ghc" and end with our version number.
197198ghcPred :: FilePath -> Bool
198- ghcPred path = isPrefixOf " ghc" (basename path) && isSuffixOf ghcVersionNumber path
199+ ghcPred path = isPrefixOf " ghc" (takeFileName path) && isSuffixOf ghcVersionNumber path
199200
200201findStackPackageDb :: IO (Maybe FilePath )
201202findStackPackageDb = do
@@ -212,7 +213,7 @@ findStackPackageDb = do
212213-- The GHC version path might look like {hash}/8.10.4/lib/x86_64-linux-ghc-8.10.4
213214-- We want to get the package path, at {hash}/8.10.4/pkgdb
214215pkgPathFromGhcPath :: FilePath -> FilePath
215- pkgPathFromGhcPath ghcVersionDir = pathJoin (dropDirectoryLevel (dropDirectoryLevel ghcVersionDir)) " pkgdb"
216+ pkgPathFromGhcPath ghcVersionDir = takeDirectory (takeDirectory ghcVersionDir) </> " pkgdb"
216217
217218snapshotPackagePredicate :: FilePath -> IO Bool
218219snapshotPackagePredicate fp = if not (ghcVersion `isSuffixOf` fp)
@@ -241,15 +242,15 @@ findStackSnapshotsDir = if isWindows
241242findStackSnapshotsDirUnix :: IO (Maybe FilePath )
242243findStackSnapshotsDirUnix = do
243244 homeDir <- getHomeDirectory
244- let dir = homeDir `pathJoin` " .stack" `pathJoin` " snapshots"
245+ let dir = homeDir </> " .stack" </> " snapshots"
245246 returnIfDirExists dir
246247
247248findStackSnapshotsDirWindows :: IO (Maybe FilePath )
248249findStackSnapshotsDirWindows = do
249250 dir' <- lookupEnv " STACK_ROOT"
250251 case dir' of
251252 Nothing -> return Nothing
252- Just dir -> returnIfDirExists (dir `pathJoin` " snapshots" )
253+ Just dir -> returnIfDirExists (dir </> " snapshots" )
253254
254255findGhcSearchDir :: IO (Maybe FilePath )
255256findGhcSearchDir = if isWindows
@@ -261,9 +262,9 @@ findGhcSearchDirUnix = do
261262 isCi <- envIsCi
262263 homeDir <- if isCi
263264 -- Unintuitively, "/home" is not the same as "~" on Circle CI
264- then return (" /home" `pathJoin` " stackage" )
265+ then return (" /home" </> " stackage" )
265266 else getHomeDirectory
266- let dir = homeDir `pathJoin` " .stack" `pathJoin` " programs"
267+ let dir = homeDir </> " .stack" </> " programs"
267268 returnIfDirExists dir
268269
269270findGhcSearchDirWindows :: IO (Maybe FilePath )
@@ -272,5 +273,5 @@ findGhcSearchDirWindows = do
272273 case localAppDataDir' of
273274 Nothing -> return Nothing
274275 Just localAppDataDir -> do
275- let dir = localAppDataDir `pathJoin` " Programs" `pathJoin` " stack"
276+ let dir = localAppDataDir </> " Programs" </> " stack"
276277 returnIfDirExists dir
0 commit comments