[commit: ghc] master: Document Safe Haskell restrictions on Generic instances (b3d55e2)

git at git.haskell.org git at git.haskell.org
Fri Sep 30 19:55:12 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/b3d55e20d20344bfc09f4ca4a554a819c4ecbfa8/ghc

>---------------------------------------------------------------

commit b3d55e20d20344bfc09f4ca4a554a819c4ecbfa8
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Fri Sep 30 15:52:02 2016 -0400

    Document Safe Haskell restrictions on Generic instances
    
    Commit 578fbeca31dd3d755e24e910c3a7327f92bc4ee3 disallowed hand-written
    `Generic` instances in Safe Haskell, but this wasn't documented anywhere.


>---------------------------------------------------------------

b3d55e20d20344bfc09f4ca4a554a819c4ecbfa8
 docs/users_guide/safe_haskell.rst | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/docs/users_guide/safe_haskell.rst b/docs/users_guide/safe_haskell.rst
index 3914820..6ce8b8f 100644
--- a/docs/users_guide/safe_haskell.rst
+++ b/docs/users_guide/safe_haskell.rst
@@ -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



More information about the ghc-commits mailing list