... | ... | @@ -29,6 +29,35 @@ data family T :: k -> Type |
|
|
data instance T (a :: Type) = MkT1 a
|
|
|
```
|
|
|
|
|
|
### Stricter scope-checking for associated type family instances
|
|
|
|
|
|
GHC is now 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:
|
|
|
|
|
|
```hs
|
|
|
class Funct f where
|
|
|
type Codomain f
|
|
|
instance Funct ('KProxy :: KProxy o) where
|
|
|
type Codomain 'KProxy = NatTr (Proxy :: o -> Type)
|
|
|
```
|
|
|
|
|
|
Where:
|
|
|
|
|
|
```hs
|
|
|
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 the `Codomain` 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). This program can be repaired in a backwards-compatible way by mentioning `o` on the left-hand side:
|
|
|
|
|
|
```hs
|
|
|
instance Funct ('KProxy :: KProxy o) where
|
|
|
type Codomain ('KProxy @o) = NatTr (Proxy :: o -> Type)
|
|
|
-- Alternatively,
|
|
|
-- type Codomain ('KProxy :: KProxy o) = NatTr (Proxy :: o -> Type)
|
|
|
```
|
|
|
|
|
|
---
|
|
|
|
|
|
## Library changes
|
... | ... | |