Skip to content

Commit

Permalink
Support (only) Cabal 3.14
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjaguarpaw committed Sep 28, 2024
1 parent 2251e77 commit 71b71a5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion extensions.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ library
-- this causes problems in practice let's
-- revisit this decision and come up with
-- another approach.
, Cabal ^>= 3.12
, Cabal ^>= 3.14
, containers >= 0.6 && < 0.8
, directory ^>= 1.3
, filepath >= 1.4 && < 1.6
Expand Down
21 changes: 15 additions & 6 deletions src/Extensions/Cabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ extractCabalExtensions GenericPackageDescription{..} = mconcat
foreignToExtensions = condTreeToExtensions (const []) foreignLibBuildInfo

exeToExtensions :: CondTree var deps Executable -> IO (Map FilePath ParsedExtensions)
exeToExtensions = condTreeToExtensions (\Executable{..} -> [modulePath]) buildInfo
exeToExtensions = condTreeToExtensions (\Executable{..} -> [getSymbolicPath 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 -> [path]
TestSuiteExeV10 _ path -> [getSymbolicPath path]
TestSuiteLibV09 _ m -> [toModulePath m]
TestSuiteUnsupported _ -> []

Expand All @@ -133,7 +133,7 @@ extractCabalExtensions GenericPackageDescription{..} = mconcat
where
benchMainPath :: Benchmark -> [FilePath]
benchMainPath Benchmark{..} = case benchmarkInterface of
BenchmarkExeV10 _ path -> [path]
BenchmarkExeV10 _ path -> [getSymbolicPath path]
BenchmarkUnsupported _ -> []

condTreeToExtensions
Expand Down Expand Up @@ -399,16 +399,25 @@ toGhcExtension = \case
Cabal.TypeAbstractions -> Nothing
#endif
#if __GLASGOW_HASKELL__ >= 910
-- This branch cannot be satisfied yet but we're including it so
-- we don't forget to enable RequiredTypeArguments when it
-- becomes available.
Cabal.RequiredTypeArguments -> Just RequiredTypeArguments
Cabal.ExtendedLiterals -> Just ExtendedLiterals
Cabal.ListTuplePuns -> Just ListTuplePuns
#else
Cabal.RequiredTypeArguments -> Nothing
Cabal.ExtendedLiterals -> Nothing
Cabal.ListTuplePuns -> Nothing
#endif
#if __GLASGOW_HASKELL__ >= 912
-- This branch cannot be satisfied yet but we're including it so
-- we don't forget to enable RequiredTypeArguments when it
-- becomes available.
Cabal.NamedDefaults -> Just NamedDefaults
Cabal.MultilineStrings -> Just MultilineStrings
Cabal.OrPatterns -> Just OrPatterns
#else
Cabal.NamedDefaults -> Nothing
Cabal.MultilineStrings -> Nothing
Cabal.OrPatterns -> Nothing
#endif
-- GHC extensions, parsed by both Cabal and GHC, but don't have an Extension constructor
Cabal.Safe -> Nothing
Expand Down

0 comments on commit 71b71a5

Please sign in to comment.