... | ... | @@ -137,6 +137,57 @@ foo :: forall a. (Show a => a -> a) -> () |
|
|
foo _ = undefined
|
|
|
```
|
|
|
|
|
|
### GHC is pickier about inferred type signatures
|
|
|
|
|
|
GHC now performs more validity checks on inferred type signatures. One consequence of this change is that some programs that used to be accepted will no longer compile without enabling the required language extensions. For example, in these two modules:
|
|
|
|
|
|
```hs
|
|
|
{-# LANGUAGE RankNTypes #-}
|
|
|
module A where
|
|
|
|
|
|
foo :: (forall a. a -> a) -> b -> b
|
|
|
foo f x = f x
|
|
|
```
|
|
|
```hs
|
|
|
module B where
|
|
|
|
|
|
import A
|
|
|
|
|
|
bar = foo
|
|
|
```
|
|
|
|
|
|
Notice that `A` enables `RankNTypes`, but `B` does not. Previous versions of GHC would allow `bar` to typecheck, even though its inferred type is higher-rank. GHC 8.10 will now reject this, as one must now enable `RankNTypes` in `B` to accept the inferred type signature.
|
|
|
|
|
|
### The order of TH splices is more important
|
|
|
|
|
|
GHC's constraint solver now solves constraints in each top-level group sooner. This has practical consequences for Template Haskell, as TH splices necessarily separate top-level groups. For example, the following program would compile in previous versions of GHC, but not in GHC 8.10:
|
|
|
|
|
|
```hs
|
|
|
data T = MkT
|
|
|
|
|
|
tStr :: String
|
|
|
tStr = show MkT
|
|
|
|
|
|
$(return [])
|
|
|
|
|
|
instance Show T where
|
|
|
show MkT = "MkT"
|
|
|
```
|
|
|
|
|
|
This is because each top-level group's constraints are solved before moving on to the next, and since the top-level group for `tStr` appears before the top-level group that defines a `Show T` instance, GHC 8.10 will throw an error about a missing `Show T` instance in the expression `show MkT`. The issue can be fixed by rearranging the order of declarations. For instance, the following _will_ compile:
|
|
|
|
|
|
```hs
|
|
|
data T = MkT
|
|
|
|
|
|
instance Show T where
|
|
|
show MkT = "MkT"
|
|
|
|
|
|
$(return [])
|
|
|
|
|
|
tStr :: String
|
|
|
tStr = show MkT
|
|
|
```
|
|
|
|
|
|
### New `RecordWildCards` warnings
|
|
|
|
|
|
GHC 8.10 introduces two new flags, `-Wunused-record-wildcards` and `-Wredundant-record-wildcards`, which are implied by `-Wall`. This means that certain programs that use `RecordWildCards` will trigger warnings that did not do so previously. For instance, the following program emits no warnings on old versions of GHC, but will warn with GHC 8.10:
|
... | ... | |