diff --git a/Cabal-syntax/src/Language/Haskell/Extension.hs b/Cabal-syntax/src/Language/Haskell/Extension.hs index d5fb797eea6..7ba005d84dd 100644 --- a/Cabal-syntax/src/Language/Haskell/Extension.hs +++ b/Cabal-syntax/src/Language/Haskell/Extension.hs @@ -16,6 +16,7 @@ module Language.Haskell.Extension ( Language (..) , knownLanguages + , defaultDefLang , classifyLanguage , Extension (..) , KnownExtension (..) @@ -67,6 +68,10 @@ instance NFData Language where rnf = genericRnf knownLanguages :: [Language] knownLanguages = [Haskell98, Haskell2010, GHC2021] +-- | When @default-language@ is missing, 'Haskell98' is the choice. +defaultDefLang :: Language +defaultDefLang = Haskell98 + instance Pretty Language where pretty (UnknownLanguage other) = Disp.text other pretty other = Disp.text (show other) diff --git a/Cabal/src/Distribution/Simple/GHC/Internal.hs b/Cabal/src/Distribution/Simple/GHC/Internal.hs index 0574a868ba7..09d05c58851 100644 --- a/Cabal/src/Distribution/Simple/GHC/Internal.hs +++ b/Cabal/src/Distribution/Simple/GHC/Internal.hs @@ -583,7 +583,7 @@ componentGhcOptions verbosity lbi bi clbi odir = , ghcOptDebugInfo = toFlag (withDebugInfo lbi) , ghcOptExtra = hcOptions GHC bi , ghcOptExtraPath = toNubListR $ exe_paths - , ghcOptLanguage = toFlag (fromMaybe Haskell98 (defaultLanguage bi)) + , ghcOptLanguage = toFlag (fromMaybe defaultDefLang (defaultLanguage bi)) , -- Unsupported extensions have already been checked by configure ghcOptExtensions = toNubListR $ usedExtensions bi , ghcOptExtensionMap = Map.fromList . compilerExtensions $ (compiler lbi) diff --git a/Cabal/src/Distribution/Simple/HaskellSuite.hs b/Cabal/src/Distribution/Simple/HaskellSuite.hs index d59c4703fc4..4a35de13ad8 100644 --- a/Cabal/src/Distribution/Simple/HaskellSuite.hs +++ b/Cabal/src/Distribution/Simple/HaskellSuite.hs @@ -181,7 +181,7 @@ buildLib verbosity pkg_descr lbi lib clbi = do bi = libBuildInfo lib srcDirs = map getSymbolicPath (hsSourceDirs bi) ++ [odir] dbStack = withPackageDB lbi - language = fromMaybe Haskell98 (defaultLanguage bi) + language = fromMaybe defaultDefLang (defaultLanguage bi) progdb = withPrograms lbi pkgid = packageId pkg_descr diff --git a/cabal-install/src/Distribution/Client/CmdRepl.hs b/cabal-install/src/Distribution/Client/CmdRepl.hs index e243eb82974..3c72f989cc1 100644 --- a/cabal-install/src/Distribution/Client/CmdRepl.hs +++ b/cabal-install/src/Distribution/Client/CmdRepl.hs @@ -154,7 +154,7 @@ import Distribution.Verbosity , normal ) import Language.Haskell.Extension - ( Language (..) + ( defaultDefLang ) import Control.Monad (mapM) @@ -304,7 +304,7 @@ replAction flags@NixStyleFlags{extraFlags = r@ReplFlags{..}, ..} targetStrings g lBuildInfo = emptyBuildInfo { targetBuildDepends = [baseDep] - , defaultLanguage = Just Haskell2010 + , defaultLanguage = Just defaultDefLang } baseDep = Dependency "base" anyVersion mainLibSet diff --git a/cabal-install/src/Distribution/Client/ScriptUtils.hs b/cabal-install/src/Distribution/Client/ScriptUtils.hs index 1793f6aa07d..f88b767a0cf 100644 --- a/cabal-install/src/Distribution/Client/ScriptUtils.hs +++ b/cabal-install/src/Distribution/Client/ScriptUtils.hs @@ -179,7 +179,7 @@ import Distribution.Verbosity ( normal ) import Language.Haskell.Extension - ( Language (..) + ( defaultDefLang ) import Control.Concurrent.MVar @@ -377,7 +377,7 @@ withContextAndSelectors noTargets kind flags@NixStyleFlags{..} targetStrings glo executable' = executable - & L.buildInfo . L.defaultLanguage %~ maybe (Just Haskell2010) Just + & L.buildInfo . L.defaultLanguage %~ maybe (Just defaultDefLang) Just & L.buildInfo . L.options %~ fmap (setExePath exePathRel) createDirectoryIfMissingVerbose verbosity True (takeDirectory exePath) diff --git a/doc/cabal-package-description-file.rst b/doc/cabal-package-description-file.rst index 8e5e59db1cf..e87875bcf64 100644 --- a/doc/cabal-package-description-file.rst +++ b/doc/cabal-package-description-file.rst @@ -1732,7 +1732,7 @@ system-dependent values for these fields. - ``GHC2021`` (only available for GHC version newer than ``9.2``) - ``Haskell2010`` - - ``Haskell98`` + - ``Haskell98`` (default) .. pkg-field:: other-languages: identifier :since: 1.12