[commit: packages/binary] master: Add Monoid instance for Put (bec884f)

git at git.haskell.org git at git.haskell.org
Tue Apr 19 20:30:28 UTC 2016


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

On branch  : master
Link       : http://git.haskell.org/packages/binary.git/commitdiff/bec884f96cfbd40d4842c20ef4688df9ef4f16f2

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

commit bec884f96cfbd40d4842c20ef4688df9ef4f16f2
Author: Jacob Stanley <jacob at stanley.io>
Date:   Sat Apr 9 16:45:56 2016 +1000

    Add Monoid instance for Put


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

bec884f96cfbd40d4842c20ef4688df9ef4f16f2
 src/Data/Binary/Put.hs | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/Data/Binary/Put.hs b/src/Data/Binary/Put.hs
index 85ef569..07a86c0 100644
--- a/src/Data/Binary/Put.hs
+++ b/src/Data/Binary/Put.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE CPP #-}
+{-# LANGUAGE FlexibleInstances #-}
 #if __GLASGOW_HASKELL__ >= 701 && __GLASGOW_HASKELL__ != 702
 {-# LANGUAGE Safe #-}
 #endif
@@ -134,6 +135,13 @@ instance Monad PutM where
     (>>) = (*>)
     {-# INLINE (>>) #-}
 
+instance Monoid (PutM ()) where
+    mempty = pure ()
+    {-# INLINE mempty #-}
+
+    mappend = (>>)
+    {-# INLINE mappend #-}
+
 tell :: Builder -> Put
 tell b = Put $ PairS () b
 {-# INLINE tell #-}



More information about the ghc-commits mailing list