[commit: packages/containers] changelog-foldtree, cleaned_bugfix394, master, merge-doc-target, merge-fixes-5.9, merge-restrict-fix-5.8, revert-184-generic, revert-408-bugfix_394: Define Semigroup instances for base>=4.9 (e0cfcea)
git at git.haskell.org
git at git.haskell.org
Mon Apr 17 21:38:44 UTC 2017
- Previous message: [commit: packages/containers] changelog-foldtree, cleaned_bugfix394, master, merge-doc-target, merge-fixes-5.9, merge-restrict-fix-5.8, revert-184-generic, revert-408-bugfix_394: Merge pull request #169 from hvr/pr/ghc-head-wall-clean (ce65000)
- Next message: [commit: packages/containers] changelog-foldtree, cleaned_bugfix394, master, merge-doc-target, merge-fixes-5.9, merge-restrict-fix-5.8, revert-184-generic, revert-408-bugfix_394: Rename local binding to avoid clash with `(<>)` (f9e530a)
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Repository : ssh://git@git.haskell.org/containers
On branches: changelog-foldtree,cleaned_bugfix394,master,merge-doc-target,merge-fixes-5.9,merge-restrict-fix-5.8,revert-184-generic,revert-408-bugfix_394
Link : http://git.haskell.org/packages/containers.git/commitdiff/e0cfceaf3b8d410343151bdc57f527515ecc94b5
>---------------------------------------------------------------
commit e0cfceaf3b8d410343151bdc57f527515ecc94b5
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date: Sat Nov 28 22:13:54 2015 +0100
Define Semigroup instances for base>=4.9
See https://github.com/ekmett/semigroups/issues/56 for more details
>---------------------------------------------------------------
e0cfceaf3b8d410343151bdc57f527515ecc94b5
Data/IntMap/Base.hs | 13 ++++++++++++-
Data/IntSet/Base.hs | 13 ++++++++++++-
Data/Map/Base.hs | 13 ++++++++++++-
Data/Sequence.hs | 10 ++++++++++
Data/Set/Base.hs | 14 +++++++++++++-
5 files changed, 59 insertions(+), 4 deletions(-)
diff --git a/Data/IntMap/Base.hs b/Data/IntMap/Base.hs
index 0a840f5..e22c46b 100644
--- a/Data/IntMap/Base.hs
+++ b/Data/IntMap/Base.hs
@@ -222,6 +222,9 @@ import Data.Monoid (Monoid(..))
import Data.Traversable (Traversable(traverse))
import Data.Word (Word)
#endif
+#if MIN_VERSION_base(4,9,0)
+import Data.Semigroup (Semigroup((<>), stimes), stimesIdempotentMonoid)
+#endif
import Control.DeepSeq (NFData(rnf))
import Control.Monad (liftM)
@@ -305,8 +308,16 @@ infixl 9 \\{-This comment teaches CPP correct behaviour -}
instance Monoid (IntMap a) where
mempty = empty
- mappend = union
mconcat = unions
+#if !(MIN_VERSION_base(4,9,0))
+ mappend = union
+#else
+ mappend = (<>)
+
+instance Semigroup (IntMap a) where
+ (<>) = union
+ stimes = stimesIdempotentMonoid
+#endif
instance Foldable.Foldable IntMap where
fold = go
diff --git a/Data/IntSet/Base.hs b/Data/IntSet/Base.hs
index 3dc473c..3df44cb 100644
--- a/Data/IntSet/Base.hs
+++ b/Data/IntSet/Base.hs
@@ -173,6 +173,9 @@ import Data.Maybe (fromMaybe)
import Data.Monoid (Monoid(..))
import Data.Word (Word)
#endif
+#if MIN_VERSION_base(4,9,0)
+import Data.Semigroup (Semigroup((<>), stimes), stimesIdempotentMonoid)
+#endif
import Data.Typeable
import Prelude hiding (filter, foldr, foldl, null, map)
@@ -247,8 +250,16 @@ type Key = Int
instance Monoid IntSet where
mempty = empty
- mappend = union
mconcat = unions
+#if !(MIN_VERSION_base(4,9,0))
+ mappend = union
+#else
+ mappend = (<>)
+
+instance Semigroup IntSet where
+ (<>) = union
+ stimes = stimesIdempotentMonoid
+#endif
#if __GLASGOW_HASKELL__
diff --git a/Data/Map/Base.hs b/Data/Map/Base.hs
index 569b602..5d80efe 100644
--- a/Data/Map/Base.hs
+++ b/Data/Map/Base.hs
@@ -275,6 +275,9 @@ import Control.Applicative (Applicative(..), (<$>))
import Data.Monoid (Monoid(..))
import Data.Traversable (Traversable(traverse))
#endif
+#if MIN_VERSION_base(4,9,0)
+import Data.Semigroup (Semigroup((<>), stimes), stimesIdempotentMonoid)
+#endif
import Control.DeepSeq (NFData(rnf))
import Data.Bits (shiftL, shiftR)
@@ -340,8 +343,16 @@ type role Map nominal representational
instance (Ord k) => Monoid (Map k v) where
mempty = empty
- mappend = union
mconcat = unions
+#if !(MIN_VERSION_base(4,9,0))
+ mappend = union
+#else
+ mappend = (<>)
+
+instance (Ord k) => Semigroup (Map k v) where
+ (<>) = union
+ stimes = stimesIdempotentMonoid
+#endif
#if __GLASGOW_HASKELL__
diff --git a/Data/Sequence.hs b/Data/Sequence.hs
index 089b292..447688d 100644
--- a/Data/Sequence.hs
+++ b/Data/Sequence.hs
@@ -175,6 +175,9 @@ import Data.Foldable (Foldable(foldl, foldl1, foldr, foldr1, foldMap), foldl', t
#if MIN_VERSION_base(4,8,0)
import Data.Foldable (foldr')
#endif
+#if MIN_VERSION_base(4,9,0)
+import Data.Semigroup (Semigroup((<>)))
+#endif
import Data.Traversable
import Data.Typeable
@@ -543,7 +546,14 @@ instance Read a => Read (Seq a) where
instance Monoid (Seq a) where
mempty = empty
+#if !(MIN_VERSION_base(4,9,0))
mappend = (><)
+#else
+ mappend = (<>)
+
+instance Semigroup (Seq a) where
+ (<>) = (><)
+#endif
INSTANCE_TYPEABLE1(Seq,seqTc,"Seq")
diff --git a/Data/Set/Base.hs b/Data/Set/Base.hs
index 02eb82c..01c343a 100644
--- a/Data/Set/Base.hs
+++ b/Data/Set/Base.hs
@@ -199,6 +199,9 @@ import Data.Bits (shiftL, shiftR)
#if !MIN_VERSION_base(4,8,0)
import Data.Monoid (Monoid(..))
#endif
+#if MIN_VERSION_base(4,9,0)
+import Data.Semigroup (Semigroup((<>), stimes), stimesIdempotentMonoid)
+#endif
import qualified Data.Foldable as Foldable
import Data.Typeable
import Control.DeepSeq (NFData(rnf))
@@ -245,8 +248,17 @@ type role Set nominal
instance Ord a => Monoid (Set a) where
mempty = empty
- mappend = union
mconcat = unions
+#if !(MIN_VERSION_base(4,9,0))
+ mappend = union
+#else
+ mappend = (<>)
+
+instance Ord a => Semigroup (Set a) where
+ (<>) = union
+ stimes = stimesIdempotentMonoid
+#endif
+
instance Foldable.Foldable Set where
fold = go
- Previous message: [commit: packages/containers] changelog-foldtree, cleaned_bugfix394, master, merge-doc-target, merge-fixes-5.9, merge-restrict-fix-5.8, revert-184-generic, revert-408-bugfix_394: Merge pull request #169 from hvr/pr/ghc-head-wall-clean (ce65000)
- Next message: [commit: packages/containers] changelog-foldtree, cleaned_bugfix394, master, merge-doc-target, merge-fixes-5.9, merge-restrict-fix-5.8, revert-184-generic, revert-408-bugfix_394: Rename local binding to avoid clash with `(<>)` (f9e530a)
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the ghc-commits
mailing list