From caa98f5107c76973430ddbf8beff8a7a33da4430 Mon Sep 17 00:00:00 2001 From: Max Ulidtko Date: Tue, 17 Jun 2025 19:41:15 +0200 Subject: [PATCH 1/7] cleanup: drop SymbolicPath #if's for old Cabal These are, obviously, needed for Cabal < 3.6 which is already outside the supported version range. --- src/Extensions/Cabal.hs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Extensions/Cabal.hs b/src/Extensions/Cabal.hs index bcfd8f3..5f1539d 100644 --- a/src/Extensions/Cabal.hs +++ b/src/Extensions/Cabal.hs @@ -41,9 +41,7 @@ import Distribution.Types.GenericPackageDescription (GenericPackageDescription ( import Distribution.Types.Library (Library (..)) import Distribution.Types.TestSuite (TestSuite (..)) import Distribution.Types.TestSuiteInterface (TestSuiteInterface (..)) -#if MIN_VERSION_Cabal_syntax(3,6,0) import Distribution.Utils.Path (getSymbolicPath) -#endif import GHC.LanguageExtensions.Type (Extension (..)) import System.Directory (doesFileExist) import System.FilePath ((<.>), ()) @@ -117,14 +115,14 @@ extractCabalExtensions GenericPackageDescription{..} = mconcat foreignToExtensions = condTreeToExtensions (const []) foreignLibBuildInfo exeToExtensions :: CondTree var deps Executable -> IO (Map FilePath ParsedExtensions) - exeToExtensions = condTreeToExtensions (\Executable{..} -> [getSymbolicPath modulePath]) buildInfo + exeToExtensions = condTreeToExtensions (\Executable{..} -> [modulePath]) buildInfo testToExtensions :: CondTree var deps TestSuite -> IO (Map FilePath ParsedExtensions) testToExtensions = condTreeToExtensions testMainPath testBuildInfo where testMainPath :: TestSuite -> [FilePath] testMainPath TestSuite{..} = case testInterface of - TestSuiteExeV10 _ path -> [getSymbolicPath path] + TestSuiteExeV10 _ path -> [path] TestSuiteLibV09 _ m -> [toModulePath m] TestSuiteUnsupported _ -> [] @@ -133,7 +131,7 @@ extractCabalExtensions GenericPackageDescription{..} = mconcat where benchMainPath :: Benchmark -> [FilePath] benchMainPath Benchmark{..} = case benchmarkInterface of - BenchmarkExeV10 _ path -> [getSymbolicPath path] + BenchmarkExeV10 _ path -> [path] BenchmarkUnsupported _ -> [] condTreeToExtensions @@ -147,11 +145,7 @@ condTreeToExtensions condTreeToExtensions extractModules extractBuildInfo condTree = do let comp = condTreeData condTree let buildInfo = extractBuildInfo comp -#if MIN_VERSION_Cabal_syntax(3,6,0) - let srcDirs = getSymbolicPath <$> hsSourceDirs buildInfo -#else - let srcDirs = hsSourceDirs buildInfo -#endif + let srcDirs = getSymbolicPath <$> hsSourceDirs buildInfo :: [FilePath] let modules = extractModules comp ++ map toModulePath (otherModules buildInfo ++ autogenModules buildInfo) let (safeExts, parsedExtensionsAll) = partitionEithers $ mapMaybe cabalToGhcExtension $ defaultExtensions buildInfo From e1b444ffc06d66325a96c6a50d3f92ff1c071a9b Mon Sep 17 00:00:00 2001 From: Max Ulidtko Date: Tue, 17 Jun 2025 19:53:23 +0200 Subject: [PATCH 2/7] switch to Cabal-syntax, allow cabal [3.8 .. 3.16) * Cabal-syntax is a smaller package than Cabal; reduce dependency footprint. * Using Cabal-syntax requires Cabal >= 3.8 (and 3.6, with workarounds). * In addition to GHC version checks (which guard case arms' RHS's), also guard the LHS patterns, which may not exist depending on Cabal-syntax version. In all configurations, the entire case is exhaustive, and -Werror=incomplete-patterns (in extensions.cabal) guards that. --- extensions.cabal | 12 ++---------- src/Extensions/Cabal.hs | 26 +++++++++++++++++--------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/extensions.cabal b/extensions.cabal index 8e4f824..37ff43b 100644 --- a/extensions.cabal +++ b/extensions.cabal @@ -85,16 +85,8 @@ library Extensions.Types build-depends: bytestring >= 0.10 && < 0.13 - -- We need to pin a single major version of - -- Cabal-syntax here because the main reason we use - -- Cabal-syntax is for its list of extensions. Later - -- versions have strictly more extensions, and - -- we'll have missing patterns if we try to - -- support more than one major version. If - -- this causes problems in practice let's - -- revisit this decision and come up with - -- another approach. - , Cabal-syntax ^>= 3.14 + -- NOTE: check Extensions.Cabal when bumping + , Cabal-syntax >= 3.8 && < 3.16 , containers >= 0.6 && < 0.8 , directory ^>= 1.3 , filepath >= 1.4 && < 1.6 diff --git a/src/Extensions/Cabal.hs b/src/Extensions/Cabal.hs index 5f1539d..7fbea95 100644 --- a/src/Extensions/Cabal.hs +++ b/src/Extensions/Cabal.hs @@ -380,35 +380,43 @@ toGhcExtension = \case Cabal.AlternativeLayoutRuleTransitional -> Nothing Cabal.RelaxedLayout -> Nothing #endif -#if __GLASGOW_HASKELL__ >= 906 +#if MIN_VERSION_Cabal_syntax(3,10,0) +# if __GLASGOW_HASKELL__ >= 906 Cabal.DeepSubsumption -> Just DeepSubsumption Cabal.TypeData -> Just TypeData -#else +# else Cabal.DeepSubsumption -> Nothing Cabal.TypeData -> Nothing +# endif #endif -#if __GLASGOW_HASKELL__ >= 908 +#if MIN_VERSION_Cabal_syntax(3,12,0) +# if __GLASGOW_HASKELL__ >= 908 Cabal.TypeAbstractions -> Just TypeAbstractions -#else +# else Cabal.TypeAbstractions -> Nothing -#endif -#if __GLASGOW_HASKELL__ >= 910 +# endif +# if __GLASGOW_HASKELL__ >= 910 Cabal.RequiredTypeArguments -> Just RequiredTypeArguments Cabal.ExtendedLiterals -> Just ExtendedLiterals Cabal.ListTuplePuns -> Just ListTuplePuns -#else +# else Cabal.RequiredTypeArguments -> Nothing Cabal.ExtendedLiterals -> Nothing Cabal.ListTuplePuns -> Nothing +# endif #endif -#if __GLASGOW_HASKELL__ >= 912 +#if MIN_VERSION_Cabal_syntax(3,14,0) +# if __GLASGOW_HASKELL__ >= 912 + -- This branch cannot be satisfied yet but we're including it so + -- we don't forget to enable these when they become available. Cabal.NamedDefaults -> Just NamedDefaults Cabal.MultilineStrings -> Just MultilineStrings Cabal.OrPatterns -> Just OrPatterns -#else +# else Cabal.NamedDefaults -> Nothing Cabal.MultilineStrings -> Nothing Cabal.OrPatterns -> Nothing +# endif #endif -- GHC extensions, parsed by both Cabal and GHC, but don't have an Extension constructor Cabal.Safe -> Nothing From ef6b474d580c47b081232b2b264d93e506f27b72 Mon Sep 17 00:00:00 2001 From: Max Ulidtko Date: Tue, 17 Jun 2025 20:15:51 +0200 Subject: [PATCH 3/7] test: adjust CI matrix for testing --- .github/workflows/ci.yml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee4d62b..2e6cf9e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,17 +9,21 @@ on: jobs: build: - name: ghc ${{ matrix.ghc }} + name: ghc ${{ matrix.ghc }}, cabal ${{ matrix.cabal }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: - cabal: ["3.8"] + cabal: + - "3.8" + - "3.10" + - "3.12" + - "3.14" ghc: - - "8.8.4" - - "8.10.7" - - "9.0.2" - - "9.2.4" + #- "8.8.4" + #- "8.10.7" + #- "9.0.2" + #- "9.2.4" - "9.4.8" - "9.6.3" - "9.8.1" @@ -45,7 +49,10 @@ jobs: - name: Build run: | cabal v2-update - cabal v2-build --enable-tests --enable-benchmarks + cabal v2-configure \ + --constraint 'Cabal-syntax installed' \ + --enable-tests --enable-benchmarks + cabal v2-build - name: Test run: | From 753d96637968b676140e3e5277a3ad6053ac7438 Mon Sep 17 00:00:00 2001 From: Max Ulidtko Date: Tue, 17 Jun 2025 20:20:03 +0200 Subject: [PATCH 4/7] test: unlock CI in forks --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e6cf9e..6b7287e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: steps: - uses: actions/checkout@v4 - if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/main' + # if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.ref == 'refs/heads/main' - uses: haskell-actions/setup@v2.7 name: Setup Haskell From fdb55f3e6e574ed79e8b6d9c745dd0e034d64a7e Mon Sep 17 00:00:00 2001 From: Max Ulidtko Date: Tue, 17 Jun 2025 20:44:47 +0200 Subject: [PATCH 5/7] fix: RequiredTypeArguments added in cabal-syntax 3.10 --- src/Extensions/Cabal.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Extensions/Cabal.hs b/src/Extensions/Cabal.hs index 7fbea95..2f99826 100644 --- a/src/Extensions/Cabal.hs +++ b/src/Extensions/Cabal.hs @@ -388,6 +388,11 @@ toGhcExtension = \case Cabal.DeepSubsumption -> Nothing Cabal.TypeData -> Nothing # endif +# if __GLASGOW_HASKELL__ >= 910 + Cabal.RequiredTypeArguments -> Just RequiredTypeArguments +# else + Cabal.RequiredTypeArguments -> Nothing +# endif #endif #if MIN_VERSION_Cabal_syntax(3,12,0) # if __GLASGOW_HASKELL__ >= 908 @@ -396,11 +401,9 @@ toGhcExtension = \case Cabal.TypeAbstractions -> Nothing # endif # if __GLASGOW_HASKELL__ >= 910 - Cabal.RequiredTypeArguments -> Just RequiredTypeArguments Cabal.ExtendedLiterals -> Just ExtendedLiterals Cabal.ListTuplePuns -> Just ListTuplePuns # else - Cabal.RequiredTypeArguments -> Nothing Cabal.ExtendedLiterals -> Nothing Cabal.ListTuplePuns -> Nothing # endif From 9b23e9f08cc464cb2afde72de7b7844eab7a1967 Mon Sep 17 00:00:00 2001 From: Max Ulidtko Date: Tue, 17 Jun 2025 20:53:44 +0200 Subject: [PATCH 6/7] docs: changelog entry The library interface stay exactly the same -- thus, sub-patch-level version bump. --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 082b04b..1af4aac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ `extensions` uses [PVP Versioning][1]. The changelog is available [on GitHub][2]. +## 0.1.0.4 — June, 2025 + +* Dependency footprint reduced to only `Cabal-syntax`. +* Compatibility range widened to `Cabal-syntax` `3.8`..`3.14`. + ## 0.1.0.3 — Sep 28, 2024 * Support `Cabal` `3.14` (only) From b2df9fcf0aaeedccf2b7b34c328a8b9531c98484 Mon Sep 17 00:00:00 2001 From: Max Ulidtko Date: Sat, 21 Jun 2025 17:33:21 +0200 Subject: [PATCH 7/7] fix(CI): disable 9.12 temporarily --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b7287e..c7a41a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: - "9.6.3" - "9.8.1" - "9.10.1" - - "9.12.1" + #- "9.12.1" steps: - uses: actions/checkout@v4