(ghc2024CompatibleWith ghc.v7-10-3.version).unsupportedExtensions
≡ [ "TypeApplications" ] # unsupportedBefore8-4 # [ "DerivingStrategies" ]
(ghc2024CompatibleWith ghc.v8-2-1.version).unsupportedExtensions
≡ unsupportedBefore8-4
(ghc2021CompatibleWith ghc.v7-10-3.version).unsupportedExtensions
≡ [ "TypeApplications" ] # unsupportedBefore8-4
{-| Returns a variant of the provided language edition that is compatible with
the provided GHC version.
This allows us to take advantage of newer language editions to the extent we
can, even when we use GHC versions that predate those editions.
-}
let P =
https://prelude.dhall-lang.org/v20.1.0/package.dhall
sha256:26b0ef498663d269e4dc6a82b0ee289ec565d683ef4c00d0ebdd25333a5a3c98
let Pvp = ../../PVP/package.dhall
let ghc = ../Release/package.dhall
let Edition = ./Type
let CompositeEdition = ./Composite
let Haskell2010 = ./Haskell2010
let GHC2021 = ./GHC2021
let GHC2024 = ./GHC2024
let -- Adds `extensions` to either `additionalExtensions` or
-- `unsupportedExtensions` depending on whether `minimumGhcVersion` supports
-- them.
versionExtensions =
λ(ghcVersion : Pvp.Version) →
λ(minimumGhcVersion : Pvp.Version) →
λ(extensions : List Text) →
λ(original : CompositeEdition) →
original
⫽ ( if Pvp.lessThanEqual ghcVersion minimumGhcVersion
then { additionalExtensions =
original.additionalExtensions # extensions
, unsupportedExtensions = original.unsupportedExtensions
}
else { additionalExtensions = original.additionalExtensions
, unsupportedExtensions =
original.unsupportedExtensions # extensions
}
)
let ghc2021CompatibleWith
: Pvp.Version → CompositeEdition
= λ(minimumGhcVersion : Pvp.Version) →
if Pvp.lessThanEqual ghc.v9-2-1.version minimumGhcVersion
then { name = GHC2021.name
, baseEdition = GHC2021
, additionalExtensions = [] : List Text
, unsupportedExtensions = [] : List Text
}
else versionExtensions
ghc.v8-10-1.version
minimumGhcVersion
[ "DeriveLift"
, "ImportQualifiedPost"
, "StandaloneKindSignatures"
]
( versionExtensions
ghc.v8-6-1.version
minimumGhcVersion
[ "NumericUnderscores" ]
( versionExtensions
ghc.v8-4-1.version
minimumGhcVersion
[ "EmptyDataDeriving", "HexFloatLiterals" ]
( versionExtensions
ghc.v8-0-1.version
minimumGhcVersion
[ "TypeApplications" ]
{ name = GHC2021.name
, baseEdition = Haskell2010
, additionalExtensions =
[ "BangPatterns"
, "BinaryLiterals"
, "ConstrainedClassMethods"
, "ConstraintKinds"
, "DeriveDataTypeable"
, "DeriveFoldable"
, "DeriveFunctor"
, "DeriveGeneric"
, "DeriveTraversable"
, "EmptyCase"
, "ExistentialQuantification"
, "ExplicitForAll"
, "FlexibleContexts"
, "FlexibleInstances"
, "GADTSyntax"
, "GeneralizedNewtypeDeriving"
, "InstanceSigs"
, "KindSignatures"
, "MultiParamTypeClasses"
, "NamedFieldPuns"
, "NamedWildCards"
, "PolyKinds"
, "PostfixOperators"
, "RankNTypes"
, "ScopedTypeVariables"
, "StandaloneDeriving"
, "TupleSections"
, "TypeOperators"
, "TypeSynonymInstances"
, "NoExplicitNamespaces"
]
, unsupportedExtensions = [] : List Text
}
)
)
)
let ghc2024CompatibleWith
: Pvp.Version → CompositeEdition
= λ(minimumGhcVersion : Pvp.Version) →
if Pvp.lessThanEqual ghc.v9-10-1.version minimumGhcVersion
then { name = GHC2024.name
, baseEdition = GHC2024
, additionalExtensions = [] : List Text
, unsupportedExtensions = [] : List Text
}
else let GHC2021 = ghc2021CompatibleWith minimumGhcVersion
in versionExtensions
ghc.v8-2-1.version
minimumGhcVersion
[ "DerivingStrategies" ]
( GHC2021
⫽ { name = GHC2024.name
, additionalExtensions =
GHC2021.additionalExtensions
# [ "DataKinds"
, "DisambiguateRecordFields"
, "ExplicitNamespaces"
, "GADTs"
, "LambdaCase"
, "MonoLocalBinds"
, "RoleAnnotations"
]
}
)
let unsupportedBefore8-4 =
[ "EmptyDataDeriving"
, "HexFloatLiterals"
, "NumericUnderscores"
, "DeriveLift"
, "ImportQualifiedPost"
, "StandaloneKindSignatures"
]
let checkGhc2024On7-10 =
assert
: (ghc2024CompatibleWith ghc.v7-10-3.version).unsupportedExtensions
≡ [ "TypeApplications" ]
# unsupportedBefore8-4
# [ "DerivingStrategies" ]
let checkGhc2024On8-2 =
assert
: (ghc2024CompatibleWith ghc.v8-2-1.version).unsupportedExtensions
≡ unsupportedBefore8-4
let -- GHC2021 doesn’t include `DerivingStrategies`, so unlike in
-- `checkGhc2024On7-10`, it isn’t unsupported here.
checkGhc2021On7-10 =
assert
: (ghc2021CompatibleWith ghc.v7-10-3.version).unsupportedExtensions
≡ [ "TypeApplications" ] # unsupportedBefore8-4
in λ(edition : Edition) →
if P.Natural.equal edition.year 2024
then ghc2024CompatibleWith
else if P.Natural.equal edition.year 2021
then ghc2021CompatibleWith
else λ(minimumGhcVersion : Pvp.Version) →
{ name = edition.name
, baseEdition = edition
, additionalExtensions = [] : List Text
, unsupportedExtensions = [] : List Text
}