Skip to content

Commit

Permalink
Document Haskell98 as default default-language
Browse files Browse the repository at this point in the history
Also correct two `Haskell2010` in the codebase which were not
influencing `cabal` behaviour (i.e. `Haskell98` as default).
  • Loading branch information
ffaf1 committed Mar 1, 2024
1 parent a0774dc commit 395997a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions Cabal-syntax/src/Language/Haskell/Extension.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
module Language.Haskell.Extension
( Language (..)
, knownLanguages
, defaultDefLang
, classifyLanguage
, Extension (..)
, KnownExtension (..)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/GHC/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/HaskellSuite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions cabal-install/src/Distribution/Client/CmdRepl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ import Distribution.Verbosity
, normal
)
import Language.Haskell.Extension
( Language (..)
( defaultDefLang
)

import Control.Monad (mapM)
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions cabal-install/src/Distribution/Client/ScriptUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ import Distribution.Verbosity
( normal
)
import Language.Haskell.Extension
( Language (..)
( defaultDefLang
)

import Control.Concurrent.MVar
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion doc/cabal-package-description-file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 395997a

Please sign in to comment.