Skip to content

Commit

Permalink
Support GHC2024 (fixes #9736)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgundry committed Mar 9, 2024
1 parent 2269835 commit b72ea91
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 6 deletions.
5 changes: 4 additions & 1 deletion Cabal-syntax/src/Language/Haskell/Extension.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ data Language
| -- | The GHC2021 collection of language extensions.
-- <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0380-ghc2021.rst>
GHC2021
| -- | The GHC2024 collection of language extensions.
-- <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0613-ghc2024.rst>
GHC2024
| -- | An unknown language, identified by its name.
UnknownLanguage String
deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)
Expand All @@ -65,7 +68,7 @@ instance NFData Language where rnf = genericRnf

-- | List of known (supported) languages for GHC, oldest first.
knownLanguages :: [Language]
knownLanguages = [Haskell98, Haskell2010, GHC2021]
knownLanguages = [Haskell98, Haskell2010, GHC2021, GHC2024]

instance Pretty Language where
pretty (UnknownLanguage other) = Disp.text other
Expand Down
4 changes: 4 additions & 0 deletions Cabal/src/Distribution/Simple/GHC/ImplInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ data GhcImplInfo = GhcImplInfo
-- ^ -XHaskell2010 and -XHaskell98 flags
, supportsGHC2021 :: Bool
-- ^ -XGHC2021 flag
, supportsGHC2024 :: Bool
-- ^ -XGHC2024 flag
, reportsNoExt :: Bool
-- ^ --supported-languages gives Ext and NoExt
, alwaysNondecIndent :: Bool
Expand Down Expand Up @@ -88,6 +90,7 @@ ghcVersionImplInfo ver =
GhcImplInfo
{ supportsHaskell2010 = v >= [7]
, supportsGHC2021 = v >= [9, 1]
, supportsGHC2024 = v >= [9, 9]
, reportsNoExt = v >= [7]
, alwaysNondecIndent = v < [7, 1]
, flagGhciScript = v >= [7, 2]
Expand All @@ -114,6 +117,7 @@ ghcjsVersionImplInfo _ghcjsver ghcver =
GhcImplInfo
{ supportsHaskell2010 = True
, supportsGHC2021 = True
, supportsGHC2024 = ghcv >= [9, 9]
, reportsNoExt = True
, alwaysNondecIndent = False
, flagGhciScript = True
Expand Down
7 changes: 7 additions & 0 deletions Cabal/src/Distribution/Simple/GHC/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ getLanguages
-> IO [(Language, String)]
getLanguages _ implInfo _
-- TODO: should be using --supported-languages rather than hard coding
| supportsGHC2024 implInfo =
return
[ (GHC2024, "-XGHC2024")
, (GHC2021, "-XGHC2021")
, (Haskell2010, "-XHaskell2010")
, (Haskell98, "-XHaskell98")
]
| supportsGHC2021 implInfo =
return
[ (GHC2021, "-XGHC2021")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,12 @@ languagePrompt flags pkgType = getLanguage flags $ do
let h2010 = "Haskell2010"
h98 = "Haskell98"
ghc2021 = "GHC2021 (requires at least GHC 9.2)"
ghc2024 = "GHC2024 (requires at least GHC 9.10)"

l <-
promptList
("Choose a language for your " ++ pkgType)
[h2010, h98, ghc2021]
[h2010, h98, ghc2021, ghc2024]
(DefaultPrompt h2010)
Nothing
True
Expand All @@ -469,6 +470,7 @@ languagePrompt flags pkgType = getLanguage flags $ do
| l == h2010 -> return Haskell2010
| l == h98 -> return Haskell98
| l == ghc2021 -> return GHC2021
| l == ghc2024 -> return GHC2024
| otherwise -> return $ UnknownLanguage l

noCommentsPrompt :: Interactive m => InitFlags -> m Bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ interactiveTests srcDb =
[ testNumberedPrompt
"Language indices"
(`languagePrompt` "test")
[Haskell2010, Haskell98, GHC2021]
[Haskell2010, Haskell98, GHC2021, GHC2024]
, testSimplePrompt
"Other language"
(`languagePrompt` "test")
Expand Down
11 changes: 11 additions & 0 deletions changelog.d/issue-9736
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
synopsis: Add support for `GHC2024`
packages: Cabal cabal-install
issues: #9736

description: {

Support for the `GHC2024` language edition, introduced by GHC 9.10, has been
added. It can now be used in the `default-language` and `other-languages`
fields, and will be offered as an option by `cabal init`.

}
4 changes: 2 additions & 2 deletions doc/buildinfo-fields-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ default-language
* Documentation of :pkg-field:`library:default-language`

.. math::
\left\{ \mathop{\mathord{``}\mathtt{GHC2021}\mathord{"}}\mid\mathop{\mathord{``}\mathtt{Haskell2010}\mathord{"}}\mid\mathop{\mathord{``}\mathtt{Haskell98}\mathord{"}} \right\}
\left\{ \mathop{\mathord{``}\mathtt{GHC2024}\mathord{"}}\mid\mathop{\mathord{``}\mathtt{GHC2021}\mathord{"}}\mid\mathop{\mathord{``}\mathtt{Haskell2010}\mathord{"}}\mid\mathop{\mathord{``}\mathtt{Haskell98}\mathord{"}} \right\}
extensions
* Monoidal field
Expand Down Expand Up @@ -494,7 +494,7 @@ other-languages
* Documentation of :pkg-field:`library:other-languages`

.. math::
\mathrm{optcommalist}\left\{ \mathop{\mathord{``}\mathtt{GHC2021}\mathord{"}}\mid\mathop{\mathord{``}\mathtt{Haskell2010}\mathord{"}}\mid\mathop{\mathord{``}\mathtt{Haskell98}\mathord{"}} \right\}
\mathrm{optcommalist}\left\{ \mathop{\mathord{``}\mathtt{GHC2024}\mathord{"}}\mid\mathop{\mathord{``}\mathtt{GHC2021}\mathord{"}}\mid\mathop{\mathord{``}\mathtt{Haskell2010}\mathord{"}}\mid\mathop{\mathord{``}\mathtt{Haskell98}\mathord{"}} \right\}
other-modules
* Monoidal field
Expand Down
3 changes: 2 additions & 1 deletion doc/cabal-package-description-file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1730,7 +1730,8 @@ system-dependent values for these fields.

The possible values are:

- ``GHC2021`` (only available for GHC version newer than ``9.2``)
- ``GHC2024`` (only available for GHC version ``9.10`` or later)
- ``GHC2021`` (only available for GHC version ``9.2`` or later)
- ``Haskell2010``
- ``Haskell98``

Expand Down
1 change: 1 addition & 0 deletions editors/vim/syntax/cabal.vim
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ syn keyword cabalLanguage contained
\ Haskell98
\ Haskell2010
\ GHC2021
\ GHC2024

" To update this in Cabal, `cabal repl Cabal` and:
" >>> :m *Distribution.PackageDescription.FieldGrammar
Expand Down

0 comments on commit b72ea91

Please sign in to comment.