[commit: ghc] ghc-8.2: Update docs to reflect changes to DeriveDataTypeable (46d350d)
git at git.haskell.org
git at git.haskell.org
Thu Jun 29 17:54:10 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-8.2
Link : http://ghc.haskell.org/trac/ghc/changeset/46d350d2d60791af77d1f0763b61b0f710d9b664/ghc
>---------------------------------------------------------------
commit 46d350d2d60791af77d1f0763b61b0f710d9b664
Author: Chris Martin <ch.martin at gmail.com>
Date: Mon Jun 26 14:55:15 2017 -0400
Update docs to reflect changes to DeriveDataTypeable
(cherry picked from commit 914962ca23e407efdd3429dc89adcca7bee15f28)
>---------------------------------------------------------------
46d350d2d60791af77d1f0763b61b0f710d9b664
docs/users_guide/extending_ghc.rst | 2 +-
docs/users_guide/glasgow_exts.rst | 21 ++++++++++++---------
docs/users_guide/safe_haskell.rst | 5 -----
3 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/docs/users_guide/extending_ghc.rst b/docs/users_guide/extending_ghc.rst
index 10c1b3d..a7fb538 100644
--- a/docs/users_guide/extending_ghc.rst
+++ b/docs/users_guide/extending_ghc.rst
@@ -425,7 +425,7 @@ will print out the name of any top-level non-recursive binding with the
import Control.Monad (unless)
import Data.Data
- data SomeAnn = SomeAnn deriving (Data, Typeable)
+ data SomeAnn = SomeAnn deriving Data
plugin :: Plugin
plugin = defaultPlugin {
diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst
index c738862..c116a5e 100644
--- a/docs/users_guide/glasgow_exts.rst
+++ b/docs/users_guide/glasgow_exts.rst
@@ -3590,8 +3590,7 @@ automatically derived:
``Functor``, defined in ``GHC.Base``. See :ref:`deriving-functor`.
- With :ghc-flag:`-XDeriveDataTypeable`, you can derive instances of the class
- ``Data``, defined in ``Data.Data``. See :ref:`deriving-typeable` for
- deriving ``Typeable``.
+ ``Data``, defined in ``Data.Data``. See :ref:`deriving-data`.
- With :ghc-flag:`-XDeriveFoldable`, you can derive instances of the class
``Foldable``, defined in ``Data.Foldable``. See
@@ -3906,14 +3905,19 @@ For a full specification of the algorithms used in :ghc-flag:`-XDeriveFunctor`,
:ghc-flag:`-XDeriveFoldable`, and :ghc-flag:`-XDeriveTraversable`, see
:ghc-wiki:`this wiki page <Commentary/Compiler/DeriveFunctor>`.
-.. _deriving-typeable:
+.. _deriving-data:
-Deriving ``Typeable`` instances
+Deriving ``Data`` instances
-------------------------------
.. ghc-flag:: -XDeriveDataTypeable
- Enable automatic deriving of instances for the ``Typeable`` typeclass
+ Enable automatic deriving of instances for the ``Data`` typeclass
+
+.. _deriving-typeable:
+
+Deriving ``Typeable`` instances
+-------------------------------
The class ``Typeable`` is very special:
@@ -3924,8 +3928,9 @@ The class ``Typeable`` is very special:
ensures that the programmer cannot subvert the type system by writing
bogus instances.
-- Derived instances of ``Typeable`` are ignored, and may be reported as
- an error in a later version of the compiler.
+- Derived instances of ``Typeable`` may be declared if the
+ :ghc-flag:`-XDeriveDataTypeable` extension is enabled, but they are ignored,
+ and they may be reported as an error in a later version of the compiler.
- The rules for solving \`Typeable\` constraints are as follows:
@@ -12355,7 +12360,6 @@ That being said, with the appropriate use of wrapper datatypes, the
above limitations induce no loss of generality: ::
{-# LANGUAGE ConstraintKinds #-}
- {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE StandaloneDeriving #-}
@@ -12366,7 +12370,6 @@ above limitations induce no loss of generality: ::
import GHC.StaticPtr
data Dict c = c => Dict
- deriving Typeable
g1 :: Typeable a => StaticPtr (Dict (Show a) -> a -> String)
g1 = static (\Dict -> show)
diff --git a/docs/users_guide/safe_haskell.rst b/docs/users_guide/safe_haskell.rst
index 5193f06..cdd5228 100644
--- a/docs/users_guide/safe_haskell.rst
+++ b/docs/users_guide/safe_haskell.rst
@@ -273,11 +273,6 @@ Furthermore, we restrict the following features:
this reason, the ``Data.Coerce`` module is also considered unsafe. We are
hoping to find a better solution here in the future.
-- ``Data.Typeable`` — Hand crafted instances of the Typeable type class are not allowed
- in Safe Haskell as this can easily be abused to unsafely coerce
- 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
More information about the ghc-commits
mailing list