[commit: packages/binary] master: Define Semigroup instance for base>=4.9 (f5cf518)
git at git.haskell.org
git at git.haskell.org
Sun Dec 20 21:16:33 UTC 2015
Repository : ssh://git@git.haskell.org/binary
On branch : master
Link : http://git.haskell.org/packages/binary.git/commitdiff/f5cf5188c868ef14b2fbc417761bf88cf1be3910
>---------------------------------------------------------------
commit f5cf5188c868ef14b2fbc417761bf88cf1be3910
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date: Sat Dec 19 11:23:22 2015 +0100
Define Semigroup instance for base>=4.9
This makes `binary` `-Wcompat`-clean for GHC 8.0
>---------------------------------------------------------------
f5cf5188c868ef14b2fbc417761bf88cf1be3910
src/Data/Binary/Builder/Base.hs | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/Data/Binary/Builder/Base.hs b/src/Data/Binary/Builder/Base.hs
index a1f46b5..5480dd0 100644
--- a/src/Data/Binary/Builder/Base.hs
+++ b/src/Data/Binary/Builder/Base.hs
@@ -64,7 +64,11 @@ module Data.Binary.Builder.Base (
import qualified Data.ByteString as S
import qualified Data.ByteString.Lazy as L
+#if MIN_VERSION_base(4,9,0)
+import Data.Semigroup
+#else
import Data.Monoid
+#endif
import Data.Word
import Foreign
@@ -107,10 +111,20 @@ newtype Builder = Builder {
-> IO L.ByteString
}
+#if MIN_VERSION_base(4,9,0)
+instance Semigroup Builder where
+ (<>) = append
+ {-# INLINE (<>) #-}
+#endif
+
instance Monoid Builder where
mempty = empty
{-# INLINE mempty #-}
+#if MIN_VERSION_base(4,9,0)
+ mappend = (<>)
+#else
mappend = append
+#endif
{-# INLINE mappend #-}
mconcat = foldr mappend mempty
{-# INLINE mconcat #-}
More information about the ghc-commits
mailing list