Skip to content

Commit

Permalink
Make even more forwards-compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonchinn178 authored and sloorush committed Sep 12, 2022
1 parent 54b5e55 commit 57028c1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu.hs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ provider recorder plId ideState typ contents fp fo = withIndefiniteProgress titl
in liftIO (loadConfigFile fp') >>= \case
ConfigLoaded file opts -> liftIO $ do
logWith recorder Info $ ConfigPath file
format (toConfig opts)
format opts
ConfigNotFound searchDirs -> liftIO $ do
logWith recorder Info $ NoConfigPath searchDirs
format emptyConfig
Expand Down
30 changes: 14 additions & 16 deletions plugins/hls-fourmolu-plugin/src/Ide/Plugin/Fourmolu/Shim.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

module Ide.Plugin.Fourmolu.Shim (
-- * FourmoluConfig
FourmoluConfig (..),
toConfig,
cfgFilePrinterOpts,
cfgFileFixities,
emptyConfig,

-- * FixityMap
Expand All @@ -21,29 +21,27 @@ import Ormolu.Fixity

{-- Backport FourmoluConfig --}

#if MIN_VERSION_fourmolu(0,7,0)
toConfig :: FourmoluConfig -> FourmoluConfig
toConfig = id
#else
data FourmoluConfig = FourmoluConfig
{ cfgFilePrinterOpts :: PrinterOptsPartial
, cfgFileFixities :: FixityMap
}
#if !MIN_VERSION_fourmolu(0,7,0)
type FourmoluConfig = PrinterOptsPartial

toConfig :: PrinterOptsPartial -> FourmoluConfig
toConfig opts =
FourmoluConfig
{ cfgFilePrinterOpts = opts
, cfgFileFixities = mempty
}
cfgFilePrinterOpts :: FourmoluConfig -> PrinterOptsPartial
cfgFilePrinterOpts = id

cfgFileFixities :: FourmoluConfig -> FixityMap
cfgFileFixities _ = mempty
#endif

#if MIN_VERSION_fourmolu(0,7,0)
emptyConfig :: FourmoluConfig
emptyConfig =
FourmoluConfig
{ cfgFilePrinterOpts = mempty
, cfgFileFixities = mempty
}
#else
emptyConfig :: FourmoluConfig
emptyConfig = mempty
#endif

{-- Backport FixityMap --}

Expand Down

0 comments on commit 57028c1

Please sign in to comment.