Document Safe Haskell restrictions on Generic instances
authorRyan Scott <ryan.gl.scott@gmail.com>
Fri, 30 Sep 2016 19:52:02 +0000 (15:52 -0400)
committerRyan Scott <ryan.gl.scott@gmail.com>
Fri, 30 Sep 2016 19:52:02 +0000 (15:52 -0400)
Commit 578fbeca31dd3d755e24e910c3a7327f92bc4ee3 disallowed hand-written
`Generic` instances in Safe Haskell, but this wasn't documented anywhere.

docs/users_guide/safe_haskell.rst

index 3914820..6ce8b8f 100644 (file)
@@ -278,6 +278,15 @@ Furthermore, we restrict the following features:
   between types. Derived instances (through the :ghc-flag:`-XDeriveDataTypeable`
   extension) are still allowed.
 
+- ``GHC.Generics`` — Hand crafted instances of the ``Generic`` type class are
+  not allowed in Safe Haskell. Such instances aren't strictly unsafe, but
+  there is an important invariant that a ``Generic`` instance should adhere to
+  the structure of the data type for which the instance is defined, and
+  allowing manually implemented ``Generic`` instances would break that
+  invariant. Derived instances (through the :ghc-flag:`-XDeriveGeneric`
+  extension) are still allowed. Refer to the
+  :ref:`generic programming <generic-programming>` section for more details.
+
 .. _safe-overlapping-instances:
 
 Safe Overlapping Instances