[commit: ghc] master: Make IntPtr and WordPtr as instance of Data.Data typeclass, fix #13115 (cbd4911)
git at git.haskell.org
git at git.haskell.org
Wed Sep 13 15:17:35 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/cbd491170818070aeb7edd8c547a2f0bfa891bf1/ghc
>---------------------------------------------------------------
commit cbd491170818070aeb7edd8c547a2f0bfa891bf1
Author: HE, Tao <sighingnow at gmail.com>
Date: Wed Sep 13 08:26:32 2017 -0400
Make IntPtr and WordPtr as instance of Data.Data typeclass, fix #13115
Test Plan: ./validate
Reviewers: austin, hvr, bgamari, RyanGlScott
Reviewed By: RyanGlScott
Subscribers: RyanGlScott, rwbarton, thomie
GHC Trac Issues: #13115
Differential Revision: https://phabricator.haskell.org/D3938
>---------------------------------------------------------------
cbd491170818070aeb7edd8c547a2f0bfa891bf1
libraries/base/Data/Data.hs | 8 ++++++++
libraries/base/changelog.md | 2 ++
testsuite/tests/annotations/should_fail/annfail10.stderr | 4 ++--
testsuite/tests/typecheck/should_fail/T12921.stderr | 2 +-
4 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/libraries/base/Data/Data.hs b/libraries/base/Data/Data.hs
index a120980..3d257e0 100644
--- a/libraries/base/Data/Data.hs
+++ b/libraries/base/Data/Data.hs
@@ -140,6 +140,8 @@ import GHC.Real -- So we can give Data instance for Ratio
--import GHC.IOBase -- So we can give Data instance for IO, Handle
import GHC.Ptr -- So we can give Data instance for Ptr
import GHC.ForeignPtr -- So we can give Data instance for ForeignPtr
+import Foreign.Ptr (IntPtr(..), WordPtr(..))
+ -- So we can give Data instance for IntPtr and WordPtr
--import GHC.Stable -- So we can give Data instance for StablePtr
--import GHC.ST -- So we can give Data instance for ST
--import GHC.Conc -- So we can give Data instance for MVar & Co.
@@ -1204,6 +1206,12 @@ instance Data a => Data (ForeignPtr a) where
dataTypeOf _ = mkNoRepType "GHC.ForeignPtr.ForeignPtr"
dataCast1 x = gcast1 x
+-- | @since 4.11.0.0
+deriving instance Data IntPtr
+
+-- | @since 4.11.0.0
+deriving instance Data WordPtr
+
------------------------------------------------------------------------------
-- The Data instance for Array preserves data abstraction at the cost of
-- inefficiency. We omit reflection services for the sake of data abstraction.
diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md
index b9b1756..047f6d9 100644
--- a/libraries/base/changelog.md
+++ b/libraries/base/changelog.md
@@ -30,6 +30,8 @@
* Add `iterate'`, a strict version of `iterate`, to `Data.List`
and `Data.OldList` (#3474)
+ * Add `Data` instances for `IntPtr` and `WordPtr` (#13115)
+
## 4.10.0.0 *April 2017*
* Bundled with GHC *TBA*
diff --git a/testsuite/tests/annotations/should_fail/annfail10.stderr b/testsuite/tests/annotations/should_fail/annfail10.stderr
index ee9fbe1..f7866fa 100644
--- a/testsuite/tests/annotations/should_fail/annfail10.stderr
+++ b/testsuite/tests/annotations/should_fail/annfail10.stderr
@@ -10,7 +10,7 @@ annfail10.hs:9:1: error:
instance Data.Data.Data Ordering -- Defined in ‘Data.Data’
instance Data.Data.Data Integer -- Defined in ‘Data.Data’
...plus 15 others
- ...plus 43 instances involving out-of-scope types
+ ...plus 45 instances involving out-of-scope types
(use -fprint-potential-instances to see them all)
• In the annotation: {-# ANN f 1 #-}
@@ -23,6 +23,6 @@ annfail10.hs:9:11: error:
instance Num Double -- Defined in ‘GHC.Float’
instance Num Float -- Defined in ‘GHC.Float’
...plus two others
- ...plus 15 instances involving out-of-scope types
+ ...plus 17 instances involving out-of-scope types
(use -fprint-potential-instances to see them all)
• In the annotation: {-# ANN f 1 #-}
diff --git a/testsuite/tests/typecheck/should_fail/T12921.stderr b/testsuite/tests/typecheck/should_fail/T12921.stderr
index 2c04531..079acbf 100644
--- a/testsuite/tests/typecheck/should_fail/T12921.stderr
+++ b/testsuite/tests/typecheck/should_fail/T12921.stderr
@@ -10,7 +10,7 @@ T12921.hs:4:1: error:
instance Data.Data.Data Ordering -- Defined in ‘Data.Data’
instance Data.Data.Data Integer -- Defined in ‘Data.Data’
...plus 15 others
- ...plus 43 instances involving out-of-scope types
+ ...plus 45 instances involving out-of-scope types
(use -fprint-potential-instances to see them all)
• In the annotation:
{-# ANN module "HLint: ignore Reduce duplication" #-}
More information about the ghc-commits
mailing list