-
Notifications
You must be signed in to change notification settings - Fork 29
Change instances for Product and Sum to have (NFData (f a), NFData (g a)` constraints #93
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
Comments
I made only the following changes to #if MIN_VERSION_base(4,18,0)
class (forall a. NFData (f a)) => NFData1 f where
#else
class NFData1 f where
#endif
#if MIN_VERSION_base(4,18,0)
class (forall a. NFData1 (p a)) => NFData2 p where
#else
class NFData2 p where
#endif This was the output:
The result did not change after specifying |
(fyi, @Icelandjack) |
-class (forall a. NFData (f a)) => NFData1 f where
+class (forall a. NFData a => NFData (f a)) => NFData1 f where |
Oh, with this change (and |
Hm. The new typeclass instances for #if MIN_VERSION_base(4,12,0)
-- | @since 1.4.9.0
instance (NFData (f a), NFData (g a)) => NFData (Functor.Product f g a)
-- where rnf = rnf1
-- • Could not deduce (NFData (f a1))
-- arising from a superclass required to satisfy ‘NFData1 f’,
-- arising from a use of ‘rnf1’
-- from the context: (NFData (f a), NFData (g a))
-- bound by the instance declaration
-- at /Users/mbrown/Documents/Code/Haskell/deepseq/Control/DeepSeq.hs:535:10-71
-- or from: NFData a1
-- bound by a quantified context
-- at /Users/mbrown/Documents/Code/Haskell/deepseq/Control/DeepSeq.hs:536:9-12
-- • In the expression: rnf1
-- In an equation for ‘rnf’: rnf = rnf1
-- In the instance declaration for ‘NFData (Functor.Product f g a)’
#else
-- | @since 1.4.3.0
instance (NFData1 f, NFData1 g, NFData a) => NFData (Functor.Product f g a) where
rnf = rnf1
#endif
|
Then instance can be written by hand instance (NFData (f a), NFData (g a)) => NFData (Functor.Product f g a) where
rnf (Pair x y) = rnf x `seq` rnf y The deriving instance (Eq (f a), Eq (g a)) => Eq (Product f g a) but the GHC just writes instance (Eq (f a), Eq (g a)) => Eq (Product f g a) where
Pair x y == Pair u v = x == u && y == v for us. In other words It's not possible to share code between |
Fixed by #95. |
To be aligned with change Eq1 and Ord1 instances in
base-4.18
(GHC-8.6). The #88 could done at the same time. The change inbase
is described in haskell/core-libraries-committee#10, AFAICT the rationale applies todeepseq
as well.cc @Icelandjack and @Ericson2314
The text was updated successfully, but these errors were encountered: