... | ... | @@ -174,6 +174,62 @@ or simply directly annotate the type variable with the intended kind: |
|
|
data D (a :: Type) = MkD
|
|
|
```
|
|
|
|
|
|
### `NoPolyKinds` defaults visible, dependent arguments to `Type`
|
|
|
|
|
|
When `NoPolyKinds` is enabled, GHC 9.2 will default certain arguments to `Type` that it would not default before. For example, consider these two modules:
|
|
|
|
|
|
```hs
|
|
|
{-# LANGUAGE PolyKinds #-}
|
|
|
{-# LANGUAGE RankNTypes #-}
|
|
|
{-# LANGUAGE StandaloneKindSignatures #-}
|
|
|
module A where
|
|
|
|
|
|
import Data.Kind
|
|
|
|
|
|
type T1 :: Type -> Type
|
|
|
data T1 a = MkT1
|
|
|
|
|
|
type T2 :: forall (a :: Type) -> Type
|
|
|
data T2 a = MkT2
|
|
|
```
|
|
|
```hs
|
|
|
{-# LANGUAGE NoPolyKinds #-}
|
|
|
module B where
|
|
|
|
|
|
import A
|
|
|
|
|
|
y1 = MkT1
|
|
|
y2 = MkT2
|
|
|
```
|
|
|
|
|
|
In GHC 9.0 and earlier, the types of both `y1` and `y2` would be the same:
|
|
|
|
|
|
```
|
|
|
λ> :type y1
|
|
|
y1 :: T1 a
|
|
|
λ> :type y2
|
|
|
y2 :: T2 a
|
|
|
```
|
|
|
|
|
|
In GHC 9.2, however, the `a` argument to `T2` will be defaulted to `Type`:
|
|
|
|
|
|
```
|
|
|
λ> :type y1
|
|
|
y1 :: T1 a
|
|
|
λ> :type y2
|
|
|
y2 :: T2 Type
|
|
|
```
|
|
|
|
|
|
This is because under `NoPolyKinds`, GHC 9.2 will now always default any arguments bound by a `forall` in a kind, including visible ones. If your code relies on the old behavior, this could be a breaking change. There are a couple of ways to restore the old behavior of not defaulting `a`:
|
|
|
|
|
|
1. Write an explicitly polymorphic type signature, e.g.,
|
|
|
|
|
|
```hs
|
|
|
y2 :: T2 a
|
|
|
y2 = MkT2
|
|
|
```
|
|
|
2. Enable `PolyKinds` rather than `NoPolyKinds`, which prevents the `Type` defaulting from occurring.
|
|
|
|
|
|
---
|
|
|
|
|
|
## Library changes
|
... | ... | |