[commit: packages/binary] master: Add Binary instance for Identity, from base-4.8.0.0. (333f836)

git at git.haskell.org git at git.haskell.org
Thu Jun 14 21:28:34 UTC 2018


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

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

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

commit 333f8366f86a5af86062e94897eec8ef9aee4d1d
Author: Daniel Díaz <dhelta.diaz at gmail.com>
Date:   Mon Mar 12 11:14:59 2018 -0500

    Add Binary instance for Identity, from base-4.8.0.0.


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

333f8366f86a5af86062e94897eec8ef9aee4d1d
 src/Data/Binary/Class.hs | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/Data/Binary/Class.hs b/src/Data/Binary/Class.hs
index 4d1c436..2eed93e 100644
--- a/src/Data/Binary/Class.hs
+++ b/src/Data/Binary/Class.hs
@@ -60,6 +60,9 @@ import Data.Monoid (mempty)
 #endif
 import qualified Data.Monoid as Monoid
 import Data.Monoid ((<>))
+#if MIN_VERSION_base(4,8,0)
+import Data.Functor.Identity (Identity (..))
+#endif
 #if MIN_VERSION_base(4,9,0)
 import qualified Data.List.NonEmpty as NE
 import qualified Data.Semigroup     as Semigroup
@@ -566,6 +569,12 @@ instance (Binary a, Binary b, Binary c, Binary d, Binary e,
 ------------------------------------------------------------------------
 -- Container types
 
+#if MIN_VERSION_base(4,8,0)
+instance Binary a => Binary (Identity a) where
+  put (Identity x) = put x
+  get = Identity <$> get
+#endif
+
 instance Binary a => Binary [a] where
     put = putList
     get = do n <- get :: Get Int



More information about the ghc-commits mailing list