Skip to content

Commit

Permalink
Bump Cabal dependency lower bound to 3.14
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspervdj committed Jan 14, 2025
1 parent b051d1f commit 940e848
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

- UNRELEASED
* Bump `Cabal` lower bound to 3.14

- 0.14.6.0 (2024-01-19)
* #471 Support GHC 9.8 (by Michael Peyton Jones)
* #440 Fix dissappearing `DEPRECATED` pragma on module (by Lev Dvorkin)
Expand Down
31 changes: 19 additions & 12 deletions lib/Language/Haskell/Stylish/Config/Cabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ module Language.Haskell.Stylish.Config.Cabal
--------------------------------------------------------------------------------
import Control.Monad (unless)
import qualified Data.ByteString.Char8 as BS
import Data.Either (isRight)
import Data.Foldable (traverse_)
import Data.List (nub)
import Data.Maybe (maybeToList)
import qualified Distribution.PackageDescription as Cabal
import qualified Distribution.PackageDescription.Parsec as Cabal
import qualified Distribution.Parsec as Cabal
import qualified Distribution.Simple.Utils as Cabal
import qualified Distribution.Utils.Path as Cabal
import qualified Distribution.Verbosity as Cabal
import qualified Language.Haskell.Extension as Language
import Language.Haskell.Stylish.Verbose
Expand All @@ -23,8 +23,8 @@ import System.Directory (doesFileExist,


--------------------------------------------------------------------------------
import GHC.Data.Maybe (mapMaybe)
import Language.Haskell.Stylish.Config.Internal
import GHC.Data.Maybe (mapMaybe)


--------------------------------------------------------------------------------
Expand All @@ -36,18 +36,25 @@ findLanguageExtensions verbose =

--------------------------------------------------------------------------------
-- | Find the closest .cabal file, possibly going up the directory structure.
-- TODO: use ConfigSearchStrategy here, too
findCabalFile :: Verbose -> IO (Maybe FilePath)
findCabalFile verbose = do
potentialProjectRoots <- ancestors <$> getCurrentDirectory
potentialCabalFile <- filter isRight <$>
traverse Cabal.findPackageDesc potentialProjectRoots
case potentialCabalFile of
[Right cabalFile] -> return (Just cabalFile)
_ -> do
verbose $ ".cabal file not found, directories searched: " <>
show potentialProjectRoots
verbose $ "Stylish Haskell will work basing on LANGUAGE pragmas in source files."
return Nothing
cwd <- getCurrentDirectory
go [] $ ancestors cwd
where
go :: [FilePath] -> [FilePath] -> IO (Maybe FilePath)
go searched [] = do
verbose $ ".cabal file not found, directories searched: " <>
show searched
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
potentialCabalFile <- Cabal.findPackageDesc projectRoot
case potentialCabalFile of
Right cabalFile -> pure $ Just $
Cabal.interpretSymbolicPath projectRoot cabalFile
_ -> go (p : searched) ps


--------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion stylish-haskell.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Common depends
aeson >= 0.6 && < 2.3,
base >= 4.8 && < 5,
bytestring >= 0.9 && < 0.13,
Cabal >= 3.4 && < 4.0,
Cabal >= 3.14 && < 4.0,
containers >= 0.3 && < 0.7,
directory >= 1.2.3 && < 1.4,
filepath >= 1.1 && < 1.5,
Expand Down

0 comments on commit 940e848

Please sign in to comment.