diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee4d62b..c7a41a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,26 +9,30 @@ 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" - "9.10.1" - - "9.12.1" + #- "9.12.1" 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 @@ -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: | 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) 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 bcfd8f3..2f99826 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 @@ -386,35 +380,46 @@ 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 +# if __GLASGOW_HASKELL__ >= 910 + Cabal.RequiredTypeArguments -> Just RequiredTypeArguments +# else + Cabal.RequiredTypeArguments -> 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 - Cabal.RequiredTypeArguments -> Just RequiredTypeArguments +# endif +# if __GLASGOW_HASKELL__ >= 910 Cabal.ExtendedLiterals -> Just ExtendedLiterals Cabal.ListTuplePuns -> Just ListTuplePuns -#else - Cabal.RequiredTypeArguments -> Nothing +# else 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