From a1470da3f1098b2f51e5c04310d6f139b8377f23 Mon Sep 17 00:00:00 2001 From: Melanie Phoenix Date: Sat, 28 Jan 2023 18:53:58 -0500 Subject: [PATCH 1/2] change superclasses for Data.Functor.{Sum, Product, Compose} Addresses #93. --- Control/DeepSeq.hs | 13 +++++++------ changelog.md | 2 ++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Control/DeepSeq.hs b/Control/DeepSeq.hs index c79bd5e..7225559 100644 --- a/Control/DeepSeq.hs +++ b/Control/DeepSeq.hs @@ -500,8 +500,8 @@ instance (NFData1 f, NFData1 g) => NFData1 (Compose f g) where liftRnf r = liftRnf (liftRnf r) . getCompose -- | @since 1.4.3.0 -instance (NFData1 f, NFData1 g, NFData a) => NFData (Compose f g a) where - rnf = rnf1 +instance (NFData (f (g a))) => NFData (Compose f g a) where + rnf (Compose fga) = rnf fga -- | @since 1.4.3.0 instance (NFData1 f, NFData1 g) => NFData1 (Functor.Sum f g) where @@ -509,16 +509,17 @@ instance (NFData1 f, NFData1 g) => NFData1 (Functor.Sum f g) where liftRnf rnf0 (Functor.InR r) = liftRnf rnf0 r -- | @since 1.4.3.0 -instance (NFData1 f, NFData1 g, NFData a) => NFData (Functor.Sum f g a) where - rnf = rnf1 +instance (NFData (f a), NFData (g a)) => NFData (Functor.Sum f g a) where + rnf (Functor.InL fa) = rnf fa + rnf (Functor.InR ga) = rnf ga -- | @since 1.4.3.0 instance (NFData1 f, NFData1 g) => NFData1 (Functor.Product f g) where liftRnf rnf0 (Functor.Pair f g) = liftRnf rnf0 f `seq` liftRnf rnf0 g -- | @since 1.4.3.0 -instance (NFData1 f, NFData1 g, NFData a) => NFData (Functor.Product f g a) where - rnf = rnf1 +instance (NFData (f a), NFData (g a)) => NFData (Functor.Product f g a) where + rnf (Functor.Pair fa ga) = rnf fa `seq` rnf ga instance NFData a => NFData (Ratio a) where rnf x = rnf (numerator x, denominator x) diff --git a/changelog.md b/changelog.md index 9ced552..dea7993 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,8 @@ * Add quantified superclasses to NFData(1,2) ([#88](https://github.com/haskell/deepseq/issues/88)) + * Alter superclasses for Data.Functor.{Sum, Product} + ([#95])(https://github.com/haskell/deepseq/pull/95) * Drop support for GHC < 8.6 ([#94](https://github.com/haskell/deepseq/pull/94)) From b267259dcd2b62f0be28702f59184fc9ab205878 Mon Sep 17 00:00:00 2001 From: Melanie Phoenix Date: Sun, 29 Jan 2023 09:29:50 -0500 Subject: [PATCH 2/2] version note --- Control/DeepSeq.hs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Control/DeepSeq.hs b/Control/DeepSeq.hs index 7225559..050f691 100644 --- a/Control/DeepSeq.hs +++ b/Control/DeepSeq.hs @@ -499,7 +499,9 @@ instance NFData1 Ratio where instance (NFData1 f, NFData1 g) => NFData1 (Compose f g) where liftRnf r = liftRnf (liftRnf r) . getCompose --- | @since 1.4.3.0 +-- | Note: in @deepseq-1.5.0.0@ this instance's superclasses were changed. +-- +-- @since 1.4.3.0 instance (NFData (f (g a))) => NFData (Compose f g a) where rnf (Compose fga) = rnf fga @@ -508,7 +510,9 @@ instance (NFData1 f, NFData1 g) => NFData1 (Functor.Sum f g) where liftRnf rnf0 (Functor.InL l) = liftRnf rnf0 l liftRnf rnf0 (Functor.InR r) = liftRnf rnf0 r --- | @since 1.4.3.0 +-- | Note: in @deepseq-1.5.0.0@ this instance's superclasses were changed. +-- +-- @since 1.4.3.0 instance (NFData (f a), NFData (g a)) => NFData (Functor.Sum f g a) where rnf (Functor.InL fa) = rnf fa rnf (Functor.InR ga) = rnf ga @@ -517,7 +521,9 @@ instance (NFData (f a), NFData (g a)) => NFData (Functor.Sum f g a) where instance (NFData1 f, NFData1 g) => NFData1 (Functor.Product f g) where liftRnf rnf0 (Functor.Pair f g) = liftRnf rnf0 f `seq` liftRnf rnf0 g --- | @since 1.4.3.0 +-- | Note: in @deepseq-1.5.0.0@ this instance's superclasses were changed. +-- +-- @since 1.4.3.0 instance (NFData (f a), NFData (g a)) => NFData (Functor.Product f g a) where rnf (Functor.Pair fa ga) = rnf fa `seq` rnf ga