... | @@ -10,12 +10,19 @@ This guide summarises the changes you may need to make to your code to migrate f |
... | @@ -10,12 +10,19 @@ This guide summarises the changes you may need to make to your code to migrate f |
|
### `StarIsType`
|
|
### `StarIsType`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
As part of [ this GHC proposal](https://github.com/ghc-proposals/ghc-proposals/blob/05721788de9ab6538def68c3c2c9dec50c9f24a8/proposals/0020-no-type-in-type.rst) (as amended by [ this GHC proposal](https://github.com/ghc-proposals/ghc-proposals/pull/146)), a new `StarIsType` extension was introduced, which instructs GHC to treat `*` as a synonym for `Type` (from `Data.Kind`) instead of a binary type operator.
|
|
As part of [ this GHC proposal](https://github.com/ghc-proposals/ghc-proposals/blob/05721788de9ab6538def68c3c2c9dec50c9f24a8/proposals/0020-no-type-in-type.rst) (as amended by [ this GHC proposal](https://github.com/ghc-proposals/ghc-proposals/pull/146)), a new `StarIsType` extension was introduced, which instructs GHC to treat `*` as a synonym for `Type` (from `Data.Kind`) instead of a binary type operator.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
`StarIsType` is enabled by default, and one consequence of this is that GHC will interpret any use of `*` as `Type`, even if it would have been previously interpreted as a binary type operator. A notable example of such a binary type operator is `GHC.TypeLits.*`, so code like:
|
|
`StarIsType` is enabled by default, and one consequence of this is that GHC will interpret any use of `*` as `Type`, even if it would have been previously interpreted as a binary type operator. A notable example of such a binary type operator is `GHC.TypeLits.*`, so code like:
|
|
|
|
|
|
|
|
|
|
```
|
|
```
|
|
importGHC.TypeLitsf::Proxy m ->Proxy n ->Proxy(m * n)f__=Proxy
|
|
import GHC.TypeLits
|
|
|
|
|
|
|
|
f :: Proxy m -> Proxy n -> Proxy (m * n)
|
|
|
|
f _ _ = Proxy
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
... | @@ -33,20 +40,27 @@ Will not typecheck if `StarIsType` is enabled, since `m * n` is treated as if on |
... | @@ -33,20 +40,27 @@ Will not typecheck if `StarIsType` is enabled, since `m * n` is treated as if on |
|
### `MonadFailDesugaring` by default
|
|
### `MonadFailDesugaring` by default
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GHC now enables the `MonadFailDesugaring` extension by default, as discussed in [ https://prime.haskell.org/wiki/Libraries/Proposals/MonadFail\#Transitionalstrategy](https://prime.haskell.org/wiki/Libraries/Proposals/MonadFail#Transitionalstrategy). This means that code that uses partial pattern matches in `do`-notation, such as this:
|
|
GHC now enables the `MonadFailDesugaring` extension by default, as discussed in [ https://prime.haskell.org/wiki/Libraries/Proposals/MonadFail\#Transitionalstrategy](https://prime.haskell.org/wiki/Libraries/Proposals/MonadFail#Transitionalstrategy). This means that code that uses partial pattern matches in `do`-notation, such as this:
|
|
|
|
|
|
|
|
|
|
```
|
|
```
|
|
f::[[a]]->[a]f l =do(_:xs)<- l
|
|
f :: [[a]] -> [a]
|
|
|
|
f l = do
|
|
|
|
(_:xs) <- l
|
|
xs
|
|
xs
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
|
Will now desugar to use the `fail` method from the `MonadFail` class instead of from `Monad`. That is, this code will now desugar to something resembling:
|
|
Will now desugar to use the `fail` method from the `MonadFail` class instead of from `Monad`. That is, this code will now desugar to something resembling:
|
|
|
|
|
|
|
|
|
|
```
|
|
```
|
|
import Control.Monad.Fail as Fail
|
|
import Control.Monad.Fail as Fail
|
|
|
|
|
|
f::[[a]]->[a]f l =case l of(_:xs)-> xs
|
|
f :: [[a]] -> [a]
|
|
|
|
f l = case l of
|
|
|
|
(_:xs) -> xs
|
|
_ -> Fail.fail "Pattern-match failure"
|
|
_ -> Fail.fail "Pattern-match failure"
|
|
```
|
|
```
|
|
|
|
|
... | @@ -61,10 +75,13 @@ Data types with empty `where` clauses (such as `data T where`) are no longer val |
... | @@ -61,10 +75,13 @@ Data types with empty `where` clauses (such as `data T where`) are no longer val |
|
### `-Wincomplete-patterns` now applies to patterns in guards and `MultiWayIf`
|
|
### `-Wincomplete-patterns` now applies to patterns in guards and `MultiWayIf`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Due to a bug, previous versions of GHC would not emit any `-Wincomplete-patterns` warnings at all for incomplete patterns inside of guards or `MultiWayIf` expressions. This bug has been fixed, which means that code like:
|
|
Due to a bug, previous versions of GHC would not emit any `-Wincomplete-patterns` warnings at all for incomplete patterns inside of guards or `MultiWayIf` expressions. This bug has been fixed, which means that code like:
|
|
|
|
|
|
|
|
|
|
```
|
|
```
|
|
foo::Bool->Intfoo b =if| b ->1
|
|
foo :: Bool -> Int
|
|
|
|
foo b = if | b -> 1
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
... | @@ -80,8 +97,10 @@ warning: [-Wincomplete-patterns] |
... | @@ -80,8 +97,10 @@ warning: [-Wincomplete-patterns] |
|
### `PolyKinds` is pickier
|
|
### `PolyKinds` is pickier
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GHC is now more diligent about catching illegal uses of kind polymorphism that snuck into recent GHC releases. For instance, this used to be accepted without `PolyKinds`:
|
|
GHC is now more diligent about catching illegal uses of kind polymorphism that snuck into recent GHC releases. For instance, this used to be accepted without `PolyKinds`:
|
|
|
|
|
|
|
|
|
|
```
|
|
```
|
|
class C a where
|
|
class C a where
|
|
c :: Proxy (x :: a)
|
|
c :: Proxy (x :: a)
|
... | @@ -91,8 +110,10 @@ classC a where |
... | @@ -91,8 +110,10 @@ classC a where |
|
Despite the fact that `a` is used as a kind variable in the type signature for `c`. This is now an error unless `PolyKinds` is explicitly enabled.
|
|
Despite the fact that `a` is used as a kind variable in the type signature for `c`. This is now an error unless `PolyKinds` is explicitly enabled.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Moreover, GHC 8.4 would accept the following without the use of `PolyKinds`:
|
|
Moreover, GHC 8.4 would accept the following without the use of `PolyKinds`:
|
|
|
|
|
|
|
|
|
|
```
|
|
```
|
|
f :: forall k (a :: k). Proxy a
|
|
f :: forall k (a :: k). Proxy a
|
|
f = Proxy
|
|
f = Proxy
|
... | @@ -104,25 +125,45 @@ Despite the fact that `k` is used as both a type and kind variable. This is now |
... | @@ -104,25 +125,45 @@ Despite the fact that `k` is used as both a type and kind variable. This is now |
|
### `UndecidableInstances` is pickier
|
|
### `UndecidableInstances` is pickier
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GHC now requires the `UndecidableInstances` extension in order to allow type family applications in instance contexts, as in the following code:
|
|
GHC now requires the `UndecidableInstances` extension in order to allow type family applications in instance contexts, as in the following code:
|
|
|
|
|
|
|
|
|
|
```
|
|
```
|
|
{-# LANGUAGE ConstraintKinds #-}{-# LANGUAGE FlexibleContexts #-}{-# LANGUAGE FlexibleInstances #-}{-# LANGUAGE TypeFamilies #-}importData.KindtypefamilyF a ::ConstraintclassC a where{-
|
|
{-# LANGUAGE ConstraintKinds #-}
|
|
|
|
{-# LANGUAGE FlexibleContexts #-}
|
|
|
|
{-# LANGUAGE FlexibleInstances #-}
|
|
|
|
{-# LANGUAGE TypeFamilies #-}
|
|
|
|
|
|
|
|
import Data.Kind
|
|
|
|
|
|
|
|
type family F a :: Constraint
|
|
|
|
class C a where
|
|
|
|
|
|
|
|
{-
|
|
Will error without UndecidableInstances:
|
|
Will error without UndecidableInstances:
|
|
|
|
|
|
• Illegal nested constraint ‘F a’
|
|
• Illegal nested constraint ‘F a’
|
|
(Use UndecidableInstances to permit this)
|
|
(Use UndecidableInstances to permit this)
|
|
• In the instance declaration for ‘C [[a]]’
|
|
• In the instance declaration for ‘C [[a]]’
|
|
-}instanceF a =>C[[a]]
|
|
-}
|
|
|
|
instance F a => C [[a]]
|
|
```
|
|
```
|
|
|
|
|
|
### DPH is gone
|
|
### DPH is gone
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Data Parallel Haskell and GHC's automatic vectorization support, which have been bitrotting for many years, have finally been removed. One particularly user-facing change related to this is that the `-Odph` flag is now gone, so GHC will simply error if it is passed `-Odph` as a flag. (Note that `-Odph` was simply a synonym for `-O2 -fmax-simplifier-iterations=20 -fsimplifier-phases=3`.)
|
|
Data Parallel Haskell and GHC's automatic vectorization support, which have been bitrotting for many years, have finally been removed. One particularly user-facing change related to this is that the `-Odph` flag is now gone, so GHC will simply error if it is passed `-Odph` as a flag. (Note that `-Odph` was simply a synonym for `-O2 -fmax-simplifier-iterations=20 -fsimplifier-phases=3`.)
|
|
|
|
|
|
|
|
|
|
---
|
|
---
|
|
|
|
|
|
|
|
|
|
## Library changes
|
|
## Library changes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TODO
|
|
TODO
|
|
|
|
|
|
|
|
|