summaryrefslogtreecommitdiff
path: root/docs/users_guide/8.2.1-notes.rst
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2017-01-23 09:06:04 -0500
committerRyan Scott <ryan.gl.scott@gmail.com>2017-01-23 09:06:04 -0500
commit729a5e452db530e8da8ca163fcd842faac6bd690 (patch)
tree767d0f0a36a32ad947aabd8c12d27411f1d1d925 /docs/users_guide/8.2.1-notes.rst
parent18ceb14828b96a2d2f08e962111f41c46a962983 (diff)
downloadhaskell-729a5e452db530e8da8ca163fcd842faac6bd690.tar.gz
Don't quantify implicit type variables when quoting type signatures in TH
Summary: A bug was introduced in GHC 8.0 in which Template Haskell-quoted type signatures would quantify _all_ their type variables, even the implicit ones. This would cause splices like this: ``` $([d| idProxy :: forall proxy (a :: k). proxy a -> proxy a idProxy x = x |]) ``` To splice back in something that was slightly different: ``` idProxy :: forall k proxy (a :: k). proxy a -> proxy a idProxy x = x ``` Notice that the kind variable `k` is now explicitly quantified! What's worse, this now requires the `TypeInType` extension to be enabled. This changes the behavior of Template Haskell quoting to never explicitly quantify type variables which are implicitly quantified in the source. There are some other places where this behavior pops up too, including class methods, type ascriptions, `SPECIALIZE` pragmas, foreign imports, and pattern synonynms (#13018), so I fixed those too. Fixes #13018 and #13123. Test Plan: ./validate Reviewers: simonpj, goldfire, austin, bgamari Reviewed By: simonpj, goldfire Subscribers: simonpj, mpickering, thomie Differential Revision: https://phabricator.haskell.org/D2974 GHC Trac Issues: #13018, #13123
Diffstat (limited to 'docs/users_guide/8.2.1-notes.rst')
-rw-r--r--docs/users_guide/8.2.1-notes.rst36
1 files changed, 36 insertions, 0 deletions
diff --git a/docs/users_guide/8.2.1-notes.rst b/docs/users_guide/8.2.1-notes.rst
index 094fce9eaf..7e75461ac0 100644
--- a/docs/users_guide/8.2.1-notes.rst
+++ b/docs/users_guide/8.2.1-notes.rst
@@ -148,6 +148,42 @@ Template Haskell
be ambiguous in the presence of :ghc-flag:`-XPolyKinds`.
(:ghc-ticket:`12646`)
+- Quoted type signatures are more accurate with respect to implicitly
+ quantified type variables. Before, if you quoted this: ::
+
+ [d| id :: a -> a
+ id x = x
+ |]
+
+ then the code that Template Haskell would give back to you would actually be
+ this instead: ::
+
+ id :: forall a. a -> a
+ id x = x
+
+ That is, quoting would explicitly quantify all type variables, even ones
+ that were implicitly quantified in the source. This could be especially
+ harmful if a kind variable was implicitly quantified. For example, if
+ you took this quoted declaration: ::
+
+ [d| idProxy :: forall proxy (b :: k). proxy b -> proxy b
+ idProxy x = x
+ |]
+
+ and tried to splice it back in, you'd get this instead: ::
+
+ idProxy :: forall k proxy (b :: k). proxy b -> proxy b
+ idProxy x = x
+
+ Now ``k`` is explicitly quantified, and that requires turning on
+ :ghc-flag:`-XTypeInType`, whereas the original declaration did not!
+
+ Template Haskell quoting now respects implicit quantification in type
+ signatures, so the quoted declarations above now correctly leave the
+ type variables ``a`` and ``k`` as implicitly quantified.
+ (:ghc-ticket:`13018` and :ghc-ticket:`13123`)
+
+
Runtime system
~~~~~~~~~~~~~~