2.2. Version 9.2.1¶
2.2.1. Language¶
ImpredicativeTypes
: Finally, polymorphic types have become first class! GHC 9.2 includes a full implementation of the Quick Look approach to type inference for impredicative types, as described in in the paper A quick look at impredicativity (Serrano et al, ICFP 2020). More information here: Impredicative polymorphism. This replaces the old (undefined, flaky) behaviour of theImpredicativeTypes
extension.Kind inference for data/newtype instance declarations is slightly more restrictive than before. See the user manual Kind inference for data/newtype instance declarations. This is a breaking change, albeit a fairly obscure one that corrects a specification bug.
GHC is stricter about checking for out-of-scope type variables on the right-hand sides of associated type family instances that are not bound on the left-hand side. As a result, some programs that were accidentally accepted in previous versions of GHC will now be rejected, such as this example:
class Funct f where type Codomain f instance Funct ('KProxy :: KProxy o) where type Codomain 'KProxy = NatTr (Proxy :: o -> Type)
Where:
data Proxy (a :: k) = Proxy data KProxy (t :: Type) = KProxy data NatTr (c :: o -> Type)
GHC will now reject the
o
on the right-hand side of theCodomain
instance as being out of scope, as it does not meet the requirements for being explicitly bound (as it is not mentioned on the left-hand side) nor implicitly bound (as it is not mentioned in an outermost kind signature, as required by Scoping of class parameters). This program can be repaired in a backwards-compatible way by mentioningo
on the left-hand side:instance Funct ('KProxy :: KProxy o) where type Codomain ('KProxy @o) = NatTr (Proxy :: o -> Type) -- Alternatively, -- type Codomain ('KProxy :: KProxy o) = NatTr (Proxy :: o -> Type)
2.2.2. Compiler¶
New
-Wredundant-bang-patterns
flag that enables checks for “dead” bangs. For instance, given this program:f :: Bool -> Bool f True = False f !x = x
GHC would report that the bang on
x
is redundant and can be removed since the argument was already forced in the first equation. For more details see-Wredundant-bang-patterns
.New
-finline-generics
and-finline-generics-aggressively
flags for improving performance of generics-based algorithms.For more details see
-finline-generics
and-finline-generics-aggressively
.GHCi’s
:kind!
command now expands through type synonyms in addition to type families. See:kind
.GHC now supports a flag,
-fprof-callers=⟨name⟩
, for requesting that the compiler automatically insert cost-centres on all call-sites of the named function.
2.2.3. Runtime system¶
- The heap profiler now has proper treatment of pinned
ByteArray#
s. Such heap objects will now be correctly attributed to their appropriate cost centre instead of merely being lumped into thePINNED
category. Moreover, we now correctly account for the size of the array, meaning that space lost to fragmentation is no longer counted as live data.
2.2.4. ghc-prim
library¶
Void#
is now a type synonym for the unboxed tuple(# #)
. Code usingVoid#
now has to enableUnboxedTuples
.
2.2.5. ghc
library¶
There is a significant refactoring in the solver; any type-checker plugins will have to be updated, as GHC no longer uses flattening skolems or flattening metavariables.
Type checker plugins which work with the natural numbers now should use
naturalTy
kind instead oftypeNatKind
, which has been removed.The
con_args
field ofConDeclGADT
has been renamed tocon_g_args
. This is because the type ofcon_g_args
is now different from the type of thecon_args
field inConDeclH98
:data ConDecl pass = ConDeclGADT { ... , con_g_args :: HsConDeclGADTDetails pass -- ^ Arguments; never infix , ... } | ConDeclH98 { ... , con_args :: HsConDeclH98Details pass -- ^ Arguments; can be infix , ... }
Where:
-- Introduced in GHC 9.2; was called `HsConDeclDetails` in previous versions of GHC type HsConDeclH98Details pass = HsConDetails (HsScaled pass (LBangType pass)) (XRec pass [LConDeclField pass]) -- Introduced in GHC 9.2 data HsConDeclGADTDetails pass = PrefixConGADT [HsScaled pass (LBangType pass)] | RecConGADT (XRec pass [LConDeclField pass])
Unlike Haskell98-style constructors, GADT constructors cannot be declared using infix syntax, which is why
HsConDeclGADTDetails
lacks anInfixConGADT
constructor.As a result of all this, the
con_args
field is now partial, so usingcon_args
as a top-level field selector is discouraged.
2.2.6. base
library¶
It’s possible now to promote the
Natural
type:data Coordinate = Mk2D Natural Natural type MyCoordinate = Mk2D 1 10
The separate kind
Nat
is removed and now it is just a type synonym forNatural
. As a consequence, one must enableTypeSynonymInstances
in order to define instances forNat
.The
Numeric
module recievesshowBin
andreadBin
to show and read integer numbers in binary.