[commit: packages/deepseq] master: Add instances for types formerly provided by `semigroups` (40d4db0)
git at git.haskell.org
git at git.haskell.org
Wed Apr 20 13:05:18 UTC 2016
Repository : ssh://git@git.haskell.org/deepseq
On branch : master
Link : http://git.haskell.org/packages/deepseq.git/commitdiff/40d4db0a4e81a07ecd0f1bc77b8772088e75e478
>---------------------------------------------------------------
commit 40d4db0a4e81a07ecd0f1bc77b8772088e75e478
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date: Sun Nov 29 09:16:14 2015 +0100
Add instances for types formerly provided by `semigroups`
which have moved into `base-4.9`.
Specifically these are for the (new)types:
- `Data.List.NonEmpty`
- `Data.Semigroup.Arg`
- `Data.Semigroup.First`
- `Data.Semigroup.Last`
- `Data.Semigroup.Max`
- `Data.Semigroup.Min`
- `Data.Semigroup.Option`
- `Data.Semigroup.WrappedMonoid`
Fixes #11
>---------------------------------------------------------------
40d4db0a4e81a07ecd0f1bc77b8772088e75e478
Control/DeepSeq.hs | 52 +++++++++++++++++++++++++++++++++++++++++++++++-----
changelog.md | 7 ++++++-
2 files changed, 53 insertions(+), 6 deletions(-)
diff --git a/Control/DeepSeq.hs b/Control/DeepSeq.hs
index 22221e4..49bac36 100644
--- a/Control/DeepSeq.hs
+++ b/Control/DeepSeq.hs
@@ -71,7 +71,7 @@ import Data.Complex
import Data.Array
import Data.Fixed
import Data.Version
-import Data.Monoid
+import Data.Monoid as Mon
import Data.Unique ( Unique )
import Foreign.Ptr
import Foreign.C.Types
@@ -93,6 +93,11 @@ import Data.Void ( Void, absurd )
import Numeric.Natural ( Natural )
#endif
+#if MIN_VERSION_base(4,9,0)
+import Data.List.NonEmpty ( NonEmpty (..) )
+import Data.Semigroup as Semi
+#endif
+
#if __GLASGOW_HASKELL__ >= 702
import GHC.Fingerprint.Type ( Fingerprint(..) )
import GHC.Generics
@@ -368,12 +373,12 @@ instance NFData a => NFData (Dual a) where
rnf = rnf . getDual
-- |@since 1.4.0.0
-instance NFData a => NFData (First a) where
- rnf = rnf . getFirst
+instance NFData a => NFData (Mon.First a) where
+ rnf = rnf . Mon.getFirst
-- |@since 1.4.0.0
-instance NFData a => NFData (Last a) where
- rnf = rnf . getLast
+instance NFData a => NFData (Mon.Last a) where
+ rnf = rnf . Mon.getLast
-- |@since 1.4.0.0
instance NFData Any where rnf = rnf . getAny
@@ -553,6 +558,43 @@ instance NFData ExitCode where
rnf ExitSuccess = ()
----------------------------------------------------------------------------
+-- instances previously provided by semigroups package
+
+#if MIN_VERSION_base(4,9,0)
+-- |@since 1.4.2.0
+instance NFData a => NFData (NonEmpty a) where
+ rnf (x :| xs) = rnf x `seq` rnf xs
+
+-- |@since 1.4.2.0
+instance NFData a => NFData (Min a) where
+ rnf (Min a) = rnf a
+
+-- |@since 1.4.2.0
+instance NFData a => NFData (Max a) where
+ rnf (Max a) = rnf a
+
+-- |@since 1.4.2.0
+instance (NFData a, NFData b) => NFData (Arg a b) where
+ rnf (Arg a b) = rnf a `seq` rnf b `seq` ()
+
+-- |@since 1.4.2.0
+instance NFData a => NFData (Semi.First a) where
+ rnf (Semi.First a) = rnf a
+
+-- |@since 1.4.2.0
+instance NFData a => NFData (Semi.Last a) where
+ rnf (Semi.Last a) = rnf a
+
+-- |@since 1.4.2.0
+instance NFData m => NFData (WrappedMonoid m) where
+ rnf (WrapMonoid a) = rnf a
+
+-- |@since 1.4.2.0
+instance NFData a => NFData (Option a) where
+ rnf (Option a) = rnf a
+#endif
+
+----------------------------------------------------------------------------
-- Tuples
instance (NFData a, NFData b) => NFData (a,b) where
diff --git a/changelog.md b/changelog.md
index 5c6abe1..464bdba 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,6 +1,11 @@
# Changelog for [`deepseq` package](http://hackage.haskell.org/package/deepseq)
-## 1.4.2.0 *Oct 2015*
+## 1.4.2.0 *Dec 2015*
+
+ * Added instances for types provided by `semigroups` prior to
+ `base-4.9` (i.e. `NonEmpty`, `Min`, `Max`, `Arg`,
+ `Semigroup.First`, `Semigroup.Last`, `WrappedMonoid`, and
+ `Option`) ([#11](https://github.com/haskell/deepseq/issues/11))
* Added instances for `Ptr` and `FunPtr`
([#10](https://github.com/haskell/deepseq/pull/10))
More information about the ghc-commits
mailing list