|
|
[[_TOC_]]
|
|
|
|
|
|
# GHC 8.0.x Migration Guide
|
|
|
|
|
|
|
... | ... | @@ -104,7 +106,7 @@ If you're using various bits of magic from within GHC and importing from `GHC.Pr |
|
|
|
|
|
1. The ordering of the constraints has been changed so that required constraints appear before provided constraints.
|
|
|
|
|
|
1. A single set of constraints corresponds to a set of required rather than provided constraints.
|
|
|
2. A single set of constraints corresponds to a set of required rather than provided constraints.
|
|
|
|
|
|
|
|
|
For example:
|
... | ... | @@ -143,7 +145,7 @@ pattern P4 :: ty |
|
|
|
|
|
**TLDR**: The gist of the following paragraphs is to add some variation of the following snippet to your `.cabal` file, and address the warnings emitted by GHC when compiling your package:
|
|
|
|
|
|
```wiki
|
|
|
```
|
|
|
if impl(ghc >= 8.0)
|
|
|
ghc-options: -Wcompat -Wnoncanonical-monad-instances -Wnoncanonical-monadfail-instances
|
|
|
else
|
... | ... | @@ -339,18 +341,18 @@ Notice that since `Example` has no record selector, it generated `('MetaSel 'Not |
|
|
|
|
|
- the `DataD`, `NewtypeD`, `DataInstD`, and `NewtypeInstD` constructors have a new field `Maybe Kind` ([\#10828](https://gitlab.haskell.org/ghc/ghc/issues/10828)), and take a `CxtQ` instead of a `[Name]` for the derived classes ([\#10819](https://gitlab.haskell.org/ghc/ghc/issues/10819)). If you don't know what to do, use `Nothing` for the kind signature. The field that used to be of type `[Name]` can be converted to a `CxtQ` using `mapM conT`.
|
|
|
|
|
|
```wiki
|
|
|
- dataD :: CxtQ -> Name -> [TyVarBndr] -> [ConQ] -> [Name] -> DecQ
|
|
|
+ dataD :: CxtQ -> Name -> [TyVarBndr] -> Maybe Kind -> [ConQ] -> CxtQ -> DecQ
|
|
|
```diff
|
|
|
- dataD :: CxtQ -> Name -> [TyVarBndr] -> [ConQ] -> [Name] -> DecQ
|
|
|
+ dataD :: CxtQ -> Name -> [TyVarBndr] -> Maybe Kind -> [ConQ] -> CxtQ -> DecQ
|
|
|
|
|
|
- newtypeD :: CxtQ -> Name -> [TyVarBndr] -> ConQ -> [Name] -> DecQ
|
|
|
+ newtypeD :: CxtQ -> Name -> [TyVarBndr] -> Maybe Kind -> ConQ -> CxtQ -> DecQ
|
|
|
- newtypeD :: CxtQ -> Name -> [TyVarBndr] -> ConQ -> [Name] -> DecQ
|
|
|
+ newtypeD :: CxtQ -> Name -> [TyVarBndr] -> Maybe Kind -> ConQ -> CxtQ -> DecQ
|
|
|
|
|
|
- dataInstD :: CxtQ -> Name -> [TypeQ] -> [ConQ] -> [Name] -> DecQ
|
|
|
+ dataInstD :: CxtQ -> Name -> [TypeQ] -> Maybe Kind -> [ConQ] -> CxtQ -> DecQ
|
|
|
- dataInstD :: CxtQ -> Name -> [TypeQ] -> [ConQ] -> [Name] -> DecQ
|
|
|
+ dataInstD :: CxtQ -> Name -> [TypeQ] -> Maybe Kind -> [ConQ] -> CxtQ -> DecQ
|
|
|
|
|
|
- newtypeInstD :: CxtQ -> Name -> [TypeQ] -> ConQ -> [Name] -> DecQ
|
|
|
+ newtypeInstD :: CxtQ -> Name -> [TypeQ] -> Maybe Kind -> ConQ -> CxtQ -> DecQ
|
|
|
- newtypeInstD :: CxtQ -> Name -> [TypeQ] -> ConQ -> [Name] -> DecQ
|
|
|
+ newtypeInstD :: CxtQ -> Name -> [TypeQ] -> Maybe Kind -> ConQ -> CxtQ -> DecQ
|
|
|
```
|
|
|
|
|
|
- The `Strict` datatype has been overhauled. The functional equivalent of `Strict` in `template-haskell-2.11.0.0` is `Bang`:
|
... | ... | @@ -397,10 +399,17 @@ Notice that since `Example` has no record selector, it generated `('MetaSel 'Not |
|
|
|
|
|
- The `InstanceD` constructor
|
|
|
|
|
|
GHC will decide that `Example`'s field is strict. However, if you reify `Example`, its `Bang` value will be `Bang NoSourceUnpackedness NoSourceStrictness` because the user did not put an explicit strictness annotation (`!`) in the source code. To figure out what GHC decided, use the `reifyConStrictness` function:
|
|
|
|
|
|
This was a late change introduced in GHC 8.0 RC4, see [discussion](https://mail.haskell.org/pipermail/ghc-devs/2016-April/011803.html) for more details.
|
|
|
```hs
|
|
|
reifyConStrictness :: Name -> Q [DecidedStrictness]
|
|
|
|
|
|
data DecidedStrictness = DecidedLazy
|
|
|
| DecidedStrict
|
|
|
| DecidedUnpack
|
|
|
```
|
|
|
|
|
|
of type `Dec` has an additional field of type `Maybe Overlap`. It is used to specify the overlapping behavior for the instances, as with the `{-# OVERLAP/S/PED/PING #-}` pragmas:
|
|
|
- The `InstanceD` constructor of type `Dec` has an additional field of type `Maybe Overlap`. It is used to specify the overlapping behavior for the instances, as with the `{-# OVERLAP/S/PED/PING #-}` pragmas:
|
|
|
|
|
|
```
|
|
|
data Dec = ... | InstanceD (Maybe Overlap) Cxt Type [Dec] | ...
|
... | ... | @@ -434,7 +443,7 @@ Starting with version 0.68 [hackage:hsc2hs](http://hackage.haskell.org/package/h |
|
|
|
|
|
This command was incorporated into `hsc2hs` with the release of GHC 8.0. As a result, if you have the above directive in your code, it will now emit a warning when compiled with GHC 8.0:
|
|
|
|
|
|
```wiki
|
|
|
```
|
|
|
Module.hsc:24:0: warning: "hsc_alignment" redefined [enabled by default]
|
|
|
In file included from dist/build/Module_hsc_make.c:1:0:
|
|
|
/path/to/ghc/lib/template-hsc.h:88:0: note: this is the location of the previous definition
|
... | ... | |