Skip to content

Commit

Permalink
Support up to GHC 9.6
Browse files Browse the repository at this point in the history
This requires

* Bumping some dependencies

* Pinning Cabal to ^>= 3.10, because the set of exposed extensions
  increases with every cabal release so the 'extensions' library is
  not buildable with older Cabals, without missing some cases in the
  pattern match in Cabal.hs.

* Adding support for multiple new extensions
  • Loading branch information
tomjaguarpaw committed Oct 15, 2023
1 parent 14a396f commit 69a8089
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- "9.0.2"
- "9.2.4"
- "9.4.2"
- "9.6.3"

steps:
- uses: actions/checkout@v3
Expand Down
20 changes: 15 additions & 5 deletions extensions.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ tested-with: GHC == 8.8.4
GHC == 9.0.2
GHC == 9.2.4
GHC == 9.4.2
GHC == 9.6.3

flag executable
description: Build the extensions executable
Expand All @@ -31,7 +32,7 @@ source-repository head
location: https://github.com/kowainik/extensions.git

common common-options
build-depends: base >= 4.13.0.0 && < 4.18
build-depends: base >= 4.13.0.0 && < 4.20

ghc-options: -Wall
-Wcompat
Expand Down Expand Up @@ -81,14 +82,23 @@ library
Extensions.Package
Extensions.Types

build-depends: bytestring >= 0.10 && < 0.12
, Cabal >= 3.0 && < 3.9
build-depends: bytestring >= 0.10 && < 0.13
-- We need to pin a single major version of
-- Cabal here because the main reason we use
-- Cabal 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 ^>= 3.10
, containers ^>= 0.6
, directory ^>= 1.3
, filepath ^>= 1.4
, ghc-boot-th >= 8.8.1 && < 9.5
, ghc-boot-th >= 8.8.1 && < 9.9
, parsec ^>= 3.1
, text >= 1.2.3 && < 2.1
, text >= 1.2.3 && < 2.2

executable extensions
import: common-options
Expand Down
33 changes: 33 additions & 0 deletions src/Extensions/Cabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -351,22 +351,55 @@ toGhcExtension = \case
Cabal.ImportQualifiedPost -> Just ImportQualifiedPost
Cabal.StandaloneKindSignatures -> Just StandaloneKindSignatures
Cabal.UnliftedNewtypes -> Just UnliftedNewtypes
#else
Cabal.CUSKs -> Nothing
Cabal.ImportQualifiedPost -> Nothing
Cabal.StandaloneKindSignatures -> Nothing
Cabal.UnliftedNewtypes -> Nothing
#endif
#if __GLASGOW_HASKELL__ >= 900
Cabal.LexicalNegation -> Just LexicalNegation
Cabal.QualifiedDo -> Just QualifiedDo
Cabal.LinearTypes -> Just LinearTypes
#else
Cabal.LexicalNegation -> Nothing
Cabal.QualifiedDo -> Nothing
Cabal.LinearTypes -> Nothing
#endif
#if __GLASGOW_HASKELL__ >= 902
Cabal.FieldSelectors -> Just FieldSelectors
Cabal.OverloadedRecordDot -> Just OverloadedRecordDot
Cabal.UnliftedDatatypes -> Just UnliftedDatatypes
#else
Cabal.FieldSelectors -> Nothing
Cabal.OverloadedRecordDot -> Nothing
Cabal.UnliftedDatatypes -> Nothing
#endif
#if __GLASGOW_HASKELL__ >= 904
Cabal.OverloadedRecordUpdate -> Just OverloadedRecordUpdate
Cabal.AlternativeLayoutRule -> Just AlternativeLayoutRule
Cabal.AlternativeLayoutRuleTransitional -> Just AlternativeLayoutRuleTransitional
Cabal.RelaxedLayout -> Just RelaxedLayout
#else
Cabal.OverloadedRecordUpdate -> Nothing
Cabal.AlternativeLayoutRule -> Nothing
Cabal.AlternativeLayoutRuleTransitional -> Nothing
Cabal.RelaxedLayout -> Nothing
#endif
#if __GLASGOW_HASKELL__ >= 906
Cabal.DeepSubsumption -> Just DeepSubsumption
Cabal.TypeData -> Just TypeData
#else
Cabal.DeepSubsumption -> Nothing
Cabal.TypeData -> Nothing
#endif
#if __GLASGOW_HASKELL__ >= 910
-- This branch cannot be satisfied yet but we're including it so
-- we don't forget to enablel RequiredTypeArguments when it
-- becomes available.
Cabal.RequiredTypeArguments -> Just RequiredTypeArguments
#else
Cabal.RequiredTypeArguments -> 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 69a8089

Please sign in to comment.