From 6a7656ef640b60d4079671dfc35434770cb0264a Mon Sep 17 00:00:00 2001 From: Phil de Joux Date: Mon, 1 Jan 2024 15:43:08 -0500 Subject: [PATCH] Use knownLanguages for describing Language --- Cabal-described/src/Distribution/Described.hs | 10 ++++++---- Cabal-syntax/src/Language/Haskell/Extension.hs | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cabal-described/src/Distribution/Described.hs b/Cabal-described/src/Distribution/Described.hs index 694c8221de9..b158fe02a77 100644 --- a/Cabal-described/src/Distribution/Described.hs +++ b/Cabal-described/src/Distribution/Described.hs @@ -39,8 +39,10 @@ module Distribution.Described ( ) where import Prelude - (Bool (..), Char, Either (..), Enum (..), Eq (..), Ord (..), Show (..), String, elem, fmap, foldr, id, map, maybe, otherwise, return, undefined, ($), - (.)) + ( Bool (..), Char, Either (..), Enum (..), Eq (..), Ord (..), Show (..), String + , elem, fmap, foldr, id, map, maybe, otherwise, return, reverse, undefined + , ($), (.), (<$>) + ) import Data.Functor.Identity (Identity (..)) import Data.Maybe (fromMaybe) @@ -100,7 +102,7 @@ import Distribution.Types.UnqualComponentName (UnqualComponentName) import Distribution.Utils.Path (LicenseFile, PackageDir, SourceDir, SymbolicPath) import Distribution.Verbosity (Verbosity) import Distribution.Version (Version, VersionRange) -import Language.Haskell.Extension (Extension, Language) +import Language.Haskell.Extension (Extension, Language, knownLanguages) -- | Class describing the pretty/parsec format of a. class (Pretty a, Parsec a) => Described a where @@ -422,7 +424,7 @@ instance Described IncludeRenaming where mr = describe (Proxy :: Proxy ModuleRenaming) instance Described Language where - describe _ = REUnion ["GHC2021", "Haskell2010", "Haskell98"] + describe _ = REUnion $ (REString . show) <$> reverse knownLanguages instance Described LegacyExeDependency where describe _ = RETodo diff --git a/Cabal-syntax/src/Language/Haskell/Extension.hs b/Cabal-syntax/src/Language/Haskell/Extension.hs index b95bd230024..3fe8a60b381 100644 --- a/Cabal-syntax/src/Language/Haskell/Extension.hs +++ b/Cabal-syntax/src/Language/Haskell/Extension.hs @@ -63,7 +63,7 @@ instance Structured Language instance NFData Language where rnf = genericRnf --- | List of known (supported) languages for GHC +-- | List of known (supported) languages for GHC, oldest first. knownLanguages :: [Language] knownLanguages = [Haskell98, Haskell2010, GHC2021]