... | ... | @@ -513,7 +513,55 @@ The `Unit` data type from `GHC.Tuple` has been renamed to `Solo`, per #14673/#18 |
|
|
- to use functions from `GHC.Integer`: don't need to depend on it anymore as `GHC.Integer` is now in `base`.
|
|
|
- to use GMP specific functions (prime test, secure powmod, etc.): should use another package providing these functions (e.g. [hgmp](https://hackage.haskell.org/package/hgmp)). `ghc-bignum` only exposes functions provided by all of its backends.
|
|
|
|
|
|
|
|
|
### `template-haskell-2.17.*`
|
|
|
|
|
|
TODO: Explicit specificity-related changes |
|
|
\ No newline at end of file |
|
|
GHC now exports explicit specificity in type variable binders, which means that one can now define type variables that are not eligible for visible type application (also known as _inferred_ type variables). Example:
|
|
|
|
|
|
```hs
|
|
|
id1 :: forall a. a -> a -- Here, the `a` is specified
|
|
|
id1 x = x
|
|
|
|
|
|
ex1 = id1 @Int 42 -- Typechecks. The `a` in `forall a`
|
|
|
-- is eligible for visible type application.
|
|
|
|
|
|
id2 :: forall {a}. a -> a -- Here, the `a` is inferred
|
|
|
id2 x = x
|
|
|
|
|
|
ex1 = id2 @Int 42 -- Does not typecheck. The `a` in `forall {a}`
|
|
|
-- is not eligible for visible type application.
|
|
|
```
|
|
|
|
|
|
As a result, the `TyVarBndr` data type in `template-haskell` is now parameterized by a `flag` type parameter:
|
|
|
|
|
|
```hs
|
|
|
data TyVarBndr flag = PlainTV Name flag -- ^ @a@
|
|
|
| KindedTV Name flag Kind -- ^ @(a :: k)@
|
|
|
```
|
|
|
|
|
|
There are two primary ways of instantiating `flag`:
|
|
|
|
|
|
* With `Specificity`:
|
|
|
|
|
|
```hs
|
|
|
data Specificity
|
|
|
= SpecifiedSpec -- ^ @a@. Eligible for visible type application.
|
|
|
| InferredSpec -- ^ @{a}@. Not eligible for visible type application.
|
|
|
```
|
|
|
|
|
|
This corresponds to type variable binders that can be marked as specified or inferred, such as in invisible `forall`s:
|
|
|
|
|
|
```hs
|
|
|
data Type = ForallT [TyVarBndr Specificity] Cxt Type
|
|
|
| ...
|
|
|
```
|
|
|
|
|
|
Note that `template-haskell` defines the `TyVarBndrSpec` type synonym as a convenient alias for `TyVarBndr Specificity`.
|
|
|
* With `()`. This corresponds to type variable binders where the notion of specified versus inferred is not meaningful. For example, this is used in type synonyms:
|
|
|
|
|
|
```hs
|
|
|
data TySynEqn = TySynEqn (Maybe [TyVarBndr ()]) Type Type
|
|
|
```
|
|
|
|
|
|
Note that `template-haskell` defines the `TyVarBndrUnit` type synonym as a convenient alias for `TyVarBndr ()`. Also note that the `plainTV` and `kindedTV` functions from `Language.Haskell.TH.Lib` now return `TyVarBndr ()`.
|
|
|
|
|
|
If you wish to write backwards-compatible code involving `TyVarBndr`s, you may consider using the [`Language.Haskell.TH.Datatype.TyVarBndr`](http://hackage.haskell.org/package/th-abstraction-0.4.0.0/docs/Language-Haskell-TH-Datatype-TyVarBndr.html) module from the [`th-abstraction`](http://hackage.haskell.org/package/th-abstraction) library. |
|
|
\ No newline at end of file |