Skip to content

Commit 42f8df3

Browse files
committed
Refactor: Avoid unnecessary monad constraint in convertDynFlags
1 parent b214278 commit 42f8df3

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

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

+5-6
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ descriptor plId =
4444

4545
provider :: FormattingHandler IdeState
4646
provider ideState typ contents fp fo = withIndefiniteProgress title Cancellable $ do
47-
ghc <- liftIO $ runAction "Fourmolu" ideState $ use GhcSession fp
48-
fileOpts <- case hsc_dflags . hscEnv <$> ghc of
49-
Nothing -> return []
50-
Just df -> liftIO $ convertDynFlags df
47+
fileOpts <-
48+
maybe [] (convertDynFlags . hsc_dflags . hscEnv)
49+
<$> liftIO (runAction "Fourmolu" ideState $ use GhcSession fp)
5150
useCLI <- formattingCLI <$> getConfig
5251
if useCLI
5352
then liftIO
@@ -116,7 +115,7 @@ provider ideState typ contents fp fo = withIndefiniteProgress title Cancellable
116115
FormatRange (Range (Position sl _) (Position el _)) ->
117116
RegionIndices (Just $ fromIntegral $ sl + 1) (Just $ fromIntegral $ el + 1)
118117

119-
convertDynFlags :: Monad m => DynFlags -> m [String]
118+
convertDynFlags :: DynFlags -> [String]
120119
convertDynFlags df =
121120
let pp = ["-pgmF=" <> p | not (null p)]
122121
p = sPgm_F $ Compat.settings df
@@ -125,4 +124,4 @@ convertDynFlags df =
125124
showExtension = \case
126125
Cpp -> "-XCPP"
127126
x -> "-X" ++ show x
128-
in return $ pp <> pm <> ex
127+
in pp <> pm <> ex

0 commit comments

Comments
 (0)