diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75851b0d..1f561085 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macOS-latest] - ghc: ["9.6.6", "9.8", "9.10"] + ghc: ["9.6.6", "9.8", "9.10"] #using 9.6.6 as ghc-lib-parser-9.10.1.20250103 is not compatible with ghc-9.6.7. Re-enable when sorted steps: - uses: actions/checkout@v4 diff --git a/lib/Language/Haskell/Stylish/Config/Cabal.hs b/lib/Language/Haskell/Stylish/Config/Cabal.hs index db2b6f31..b7b89afa 100644 --- a/lib/Language/Haskell/Stylish/Config/Cabal.hs +++ b/lib/Language/Haskell/Stylish/Config/Cabal.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} -------------------------------------------------------------------------------- module Language.Haskell.Stylish.Config.Cabal ( findLanguageExtensions @@ -50,11 +51,20 @@ findCabalFile verbose configSearchStrategy = case configSearchStrategy of verbose $ "Stylish Haskell will work basing on LANGUAGE pragmas in source files." return Nothing go searched (p : ps) = do - let projectRoot = Just $ Cabal.makeSymbolicPath p + +#if MIN_VERSION_Cabal(3,14,0) + let projectRoot = Just $ makeSymbolicPath p potentialCabalFile <- Cabal.findPackageDesc projectRoot +#else + potentialCabalFile <- Cabal.findPackageDesc p +#endif case potentialCabalFile of Right cabalFile -> pure $ Just $ +#if MIN_VERSION_Cabal(3,14,0) Cabal.interpretSymbolicPath projectRoot cabalFile +#else + cabalFile +#endif _ -> go (p : searched) ps diff --git a/src/Main.hs b/src/Main.hs index 31af4169..9fea036e 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -14,10 +14,6 @@ import System.Exit (exitFailure) import qualified System.IO as IO import qualified System.IO.Strict as IO.Strict --------------------------------------------------------------------------------- -#if __GLASGOW_HASKELL__ < 808 -import Data.Monoid ((<>)) -#endif -------------------------------------------------------------------------------- import Language.Haskell.Stylish @@ -108,9 +104,8 @@ stylishHaskell sa = do BC8.putStr defaultConfigBytes else do - conf <- loadConfig verbose' $ case saConfig sa of - Nothing -> SearchFromCurrentDirectory - Just fp -> UseConfig fp + conf <- loadConfig verbose' $ + maybe SearchFromCurrentDirectory UseConfig (saConfig sa) filesR <- case (saRecursive sa) of True -> findHaskellFiles (saVerbose sa) (saFiles sa) _ -> return $ saFiles sa diff --git a/stylish-haskell.cabal b/stylish-haskell.cabal index 83f01f7b..a26174fc 100644 --- a/stylish-haskell.cabal +++ b/stylish-haskell.cabal @@ -39,7 +39,7 @@ Common depends aeson >= 0.6 && < 2.3, base >= 4.8 && < 5, bytestring >= 0.9 && < 0.13, - Cabal >= 3.14 && < 4.0, + Cabal >= 3.10 && < 4.0, containers >= 0.3 && < 0.9, directory >= 1.2.3 && < 1.4, filepath >= 1.1 && < 1.6,