Skip to content

Commit eaa2791

Browse files
committed
Fourmolu: parse strings to integers before comparing versions
Whoever originally wrote this (😳) had clearly had one too many beers the night before: `show @Int` is not monotonic since e.g. "10" < "2".
1 parent 54bd3b4 commit eaa2791

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import System.Exit
3838
import System.FilePath
3939
import System.Process.Run (cwd, proc)
4040
import System.Process.Text (readCreateProcessWithExitCode)
41+
import Text.Read (readMaybe)
4142

4243
descriptor :: Recorder (WithPriority LogEvent) -> PluginId -> PluginDescriptor IdeState
4344
descriptor recorder plId =
@@ -69,10 +70,10 @@ provider recorder plId ideState typ contents fp fo = withIndefiniteProgress titl
6970
let version = do
7071
guard $ exitCode == ExitSuccess
7172
"fourmolu" : v : _ <- pure $ T.words out
72-
pure $ T.splitOn "." v
73+
traverse (readMaybe @Int . T.unpack) $ T.splitOn "." v
7374
case version of
7475
Just v -> pure CLIVersionInfo
75-
{ noCabal = v >= ["0", "7"]
76+
{ noCabal = v >= [0, 7]
7677
}
7778
Nothing -> do
7879
logWith recorder Warning $ NoVersion out

0 commit comments

Comments
 (0)