From 9bfa85b0de9cf6ee2248aaec11963f7f626edb44 Mon Sep 17 00:00:00 2001 From: Sylvain Henry Date: Wed, 5 Jul 2023 10:44:47 +0200 Subject: [PATCH] Fix Lint issues --- lib/GHCup/Cabal.hs | 3 ++- lib/GHCup/HLS.hs | 3 ++- lib/GHCup/Stack.hs | 3 ++- lib/GHCup/Version.hs | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/GHCup/Cabal.hs b/lib/GHCup/Cabal.hs index 75dbeb07..85045399 100644 --- a/lib/GHCup/Cabal.hs +++ b/lib/GHCup/Cabal.hs @@ -38,6 +38,7 @@ import Control.Monad.Trans.Resource hiding ( throwM ) import Data.Either import Data.List +import Data.Ord import Data.Maybe import Data.Versions hiding ( patch ) import Haskus.Utils.Variant.Excepts @@ -280,6 +281,6 @@ rmCabalVer ver = do when (Just ver == cSet) $ do cVers <- lift $ fmap rights getInstalledCabals - case headMay . reverse . sort $ cVers of + case headMay . sortBy (comparing Down) $ cVers of Just latestver -> setCabal latestver Nothing -> lift $ rmLink (binDir "cabal" <> exeExt) diff --git a/lib/GHCup/HLS.hs b/lib/GHCup/HLS.hs index 083f558c..8d394782 100644 --- a/lib/GHCup/HLS.hs +++ b/lib/GHCup/HLS.hs @@ -43,6 +43,7 @@ import Control.Monad.Trans.Resource import Data.ByteString ( ByteString ) import Data.Either import Data.List +import Data.Ord import Data.Maybe import Data.String ( fromString ) import Data.Text ( Text ) @@ -704,7 +705,7 @@ rmHLSVer ver = do when (Just ver == isHlsSet) $ do -- set latest hls hlsVers <- lift $ fmap rights getInstalledHLSs - case headMay . reverse . sort $ hlsVers of + case headMay . sortBy (comparing Down) $ hlsVers of Just latestver -> liftE $ setHLS latestver SetHLSOnly Nothing Nothing -> pure () diff --git a/lib/GHCup/Stack.hs b/lib/GHCup/Stack.hs index 98f8a5c6..a122a193 100644 --- a/lib/GHCup/Stack.hs +++ b/lib/GHCup/Stack.hs @@ -38,6 +38,7 @@ import Control.Monad.Trans.Resource hiding ( throwM ) import Data.Either import Data.List +import Data.Ord import Data.Maybe import Data.Versions hiding ( patch ) import Haskus.Utils.Variant.Excepts @@ -279,6 +280,6 @@ rmStackVer ver = do when (Just ver == sSet) $ do sVers <- lift $ fmap rights getInstalledStacks - case headMay . reverse . sort $ sVers of + case headMay . sortBy (comparing Down) $ sVers of Just latestver -> setStack latestver Nothing -> lift $ rmLink (binDir "stack" <> exeExt) diff --git a/lib/GHCup/Version.hs b/lib/GHCup/Version.hs index 065a49b9..aeee2bc8 100644 --- a/lib/GHCup/Version.hs +++ b/lib/GHCup/Version.hs @@ -52,7 +52,7 @@ versionCmp ver1 (VR_lteq ver2) = ver1 <= ver2 versionCmp ver1 (VR_eq ver2) = ver1 == ver2 versionRange :: V.Versioning -> VersionRange -> Bool -versionRange ver' (SimpleRange cmps) = and $ fmap (versionCmp ver') cmps +versionRange ver' (SimpleRange cmps) = all (versionCmp ver') cmps versionRange ver' (OrRange cmps range) = versionRange ver' (SimpleRange cmps) || versionRange ver' range