summaryrefslogtreecommitdiff
path: root/docs/users_guide/8.2.1-notes.rst
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2016-10-14 10:40:56 -0400
committerBen Gamari <ben@smart-cactus.org>2016-10-14 13:27:33 -0400
commitd5a4e49d657682eeb6e86ae464d281974ce2f5e2 (patch)
tree215c7bbafcd067a758c4793aed7d0d581e82a4a9 /docs/users_guide/8.2.1-notes.rst
parent8c6a3d68c0301bb985aa2a462936bbcf7584ae9c (diff)
downloadhaskell-d5a4e49d657682eeb6e86ae464d281974ce2f5e2.tar.gz
Make error when deriving an instance for a typeclass less misleading
Before, when you attempted to derive an instance for a typeclass, e.g., ``` class C1 (a :: Constraint) where class C2 where deriving instance C1 C2 ``` GHC would complain that `C2`'s data constructors aren't in scope. But that makes no sense, since typeclasses don't have constructors! By refining the checks that GHC performs when deriving, we can make the error message a little more sensible. This also cleans up a related `DeriveAnyClass` infelicity. Before, you wouldn't have been able to compile code like this: ``` import System.IO (Handle) class C a deriving instance C Handle ``` Since GHC was requiring that all data constructors of `Handle` be in scope. But `DeriveAnyClass` doesn't even generate code that mentions any data constructors, so this requirement is silly! Fixes #11509. Test Plan: make test TEST=T11509 Reviewers: simonpj, austin, bgamari Reviewed By: simonpj, bgamari Subscribers: thomie, simonpj Differential Revision: https://phabricator.haskell.org/D2558 GHC Trac Issues: #11509
Diffstat (limited to 'docs/users_guide/8.2.1-notes.rst')
-rw-r--r--docs/users_guide/8.2.1-notes.rst16
1 files changed, 15 insertions, 1 deletions
diff --git a/docs/users_guide/8.2.1-notes.rst b/docs/users_guide/8.2.1-notes.rst
index 2147dbca1d..c176a0867a 100644
--- a/docs/users_guide/8.2.1-notes.rst
+++ b/docs/users_guide/8.2.1-notes.rst
@@ -42,6 +42,20 @@ Compiler
class instance using the :ghc-flag:`-XDerivingStrategies` language extension
(see :ref:`deriving-strategies`).
+- GHC now allows standalone deriving using :ghc-flag:`-XDeriveAnyClass` on
+ any data type, even if its data constructors are not in scope. This is
+ consistent with the fact that this code (in the presence of
+ :ghc-flag:`-XDeriveAnyClass`): ::
+
+ deriving instance C T
+
+ is exactly equivalent to: ::
+
+ instance C T
+
+ and the latter code has no restrictions about whether the data constructors
+ of ``T`` are in scope.
+
GHCi
~~~~
@@ -159,7 +173,7 @@ filepath
ghc
~~~
--
+-
ghc-boot
~~~~~~~~