From 7ec6e8604cd142ffa8fe7e8aa42efb8e0b29dabf Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sat, 20 Jun 2020 14:37:38 +0200 Subject: [PATCH] Slight style changes --- lib/GHCup/Utils.hs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/GHCup/Utils.hs b/lib/GHCup/Utils.hs index 6a6104b..eef7b50 100644 --- a/lib/GHCup/Utils.hs +++ b/lib/GHCup/Utils.hs @@ -54,7 +54,7 @@ import System.IO.Error import System.Posix.FilePath ( getSearchPath , takeFileName ) -import System.Posix.Files.ByteString ( getSymbolicLinkStatus, isSymbolicLink, readSymbolicLink ) +import System.Posix.Files.ByteString ( readSymbolicLink ) import Text.Regex.Posix import URI.ByteString @@ -417,24 +417,26 @@ ghcToolFiles ver = do ([s|^([a-zA-Z0-9_-]*[a-zA-Z0-9_]-)?ghc$|] :: ByteString) ) - let ghcbinPath = toFilePath (bindir ghcbin) - ghcIsHadrian <- liftIO $ isHadrian ghcbinPath + let ghcbinPath = bindir ghcbin + ghcIsHadrian <- liftIO $ isHadrian ghcbinPath onlyUnversioned <- if ghcIsHadrian then pure id else do (Just symver) <- (B.stripPrefix (toFilePath ghcbin <> "-") . takeFileName) - <$> (liftIO $ readSymbolicLink ghcbinPath) + <$> (liftIO $ readSymbolicLink $ toFilePath ghcbinPath) when (B.null symver) (throwIO $ userError $ "Fatal: ghc symlink target is broken") pure $ filter (\x -> not $ symver `B.isSuffixOf` toFilePath x) pure $ onlyUnversioned files - where - -- GHC is moving some builds to Hadrian for bindists, which doesn't create versioned binaries + where + -- GHC is moving some builds to Hadrian for bindists, + -- which doesn't create versioned binaries. -- https://gitlab.haskell.org/haskell/ghcup-hs/issues/31 - isHadrian :: ByteString -> IO Bool - isHadrian = (not . isSymbolicLink <$>) . getSymbolicLinkStatus + isHadrian :: Path Abs -- ^ ghcbin path + -> IO Bool + isHadrian = fmap (/= SymbolicLink) . getFileType -- | This file, when residing in ~/.ghcup/ghc// signals that