Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Comment thread
ulidtko marked this conversation as resolved.
- "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'
Comment on lines -31 to +35

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be reverted before merging


- uses: haskell-actions/setup@v2.7
name: Setup Haskell
Expand All @@ -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
Comment on lines +52 to +54

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haskell-actions/setup already installs Cabal from the matrix.

the added --constraint 'Cabal-syntax installed' prevents the build from satisfying the dependency via compiling another (newest) version.

cabal v2-build

- name: Test
run: |
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 2 additions & 10 deletions extensions.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
47 changes: 26 additions & 21 deletions src/Extensions/Cabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ((<.>), (</>))
Expand Down Expand Up @@ -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 _ -> []

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading