[commit: packages/deepseq] master, wip/remove_ghc70_72_cpp: Add NFData and NFData1 instances for Compose (e0f40eb)

git at git.haskell.org git at git.haskell.org
Wed Jul 19 21:59:25 UTC 2017


Repository : ssh://git@git.haskell.org/deepseq

On branches: master,wip/remove_ghc70_72_cpp
Link       : http://git.haskell.org/packages/deepseq.git/commitdiff/e0f40eb3eba22b7c363380931db16cb9e40ffc90

>---------------------------------------------------------------

commit e0f40eb3eba22b7c363380931db16cb9e40ffc90
Author: Pepe Iborra <pepeiborra at gmail.com>
Date:   Mon Feb 27 20:44:12 2017 +0000

    Add NFData and NFData1 instances for Compose


>---------------------------------------------------------------

e0f40eb3eba22b7c363380931db16cb9e40ffc90
 Control/DeepSeq.hs | 8 ++++++++
 changelog.md       | 1 +
 2 files changed, 9 insertions(+)

diff --git a/Control/DeepSeq.hs b/Control/DeepSeq.hs
index 29c3dc1..ca36cae 100644
--- a/Control/DeepSeq.hs
+++ b/Control/DeepSeq.hs
@@ -108,6 +108,7 @@ import Data.Semigroup as Semi
 
 #if MIN_VERSION_base(4,9,0)
 import GHC.Stack.Types ( CallStack(..), SrcLoc(..) )
+import Data.Functor.Compose
 #elif MIN_VERSION_base(4,8,1)
 import GHC.Stack ( CallStack(..) )
 import GHC.SrcLoc ( SrcLoc(..) )
@@ -426,7 +427,14 @@ instance NFData (a -> b) where rnf = rwhnf
 instance NFData1 Ratio where
   liftRnf r x = r (numerator x) `seq` r (denominator x)
 
+-- | @since 1.4.3.0
+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 a => NFData (Ratio a) where
+
 #else
 instance (Integral a, NFData a) => NFData (Ratio a) where
 #endif
diff --git a/changelog.md b/changelog.md
index 3a171cf..0a9380d 100644
--- a/changelog.md
+++ b/changelog.md
@@ -13,6 +13,7 @@
     ([#13](https://github.com/haskell/deepseq/issues/13))
   * Add `NFData Ordering` ([#25](https://github.com/haskell/deepseq/pull/25))
   * Add `NFData1` and `NFData2` type classes ([#8](https://github.com/haskell/deepseq/issues/8))
+  * Add `NFData1` and `NFData` instances for Compose
 
 ## 1.4.2.0  *Apr 2016*
 



More information about the ghc-commits mailing list