Skip to content

change superclasses for Data.Functor.{Sum, Product, Compose} #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions Control/DeepSeq.hs
Original file line number Diff line number Diff line change
Expand Up @@ -499,26 +499,33 @@ 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
instance (NFData1 f, NFData1 g, NFData a) => NFData (Compose f g a) where
rnf = rnf1
-- | 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

-- | @since 1.4.3.0
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
instance (NFData1 f, NFData1 g, NFData a) => NFData (Functor.Sum f g a) where
rnf = rnf1
-- | 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

-- | @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
-- | 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

instance NFData a => NFData (Ratio a) where
rnf x = rnf (numerator x, denominator x)
Expand Down
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down