Skip to content

Commit ecf48c4

Browse files
authored
Merge pull request #146 from Daniel-Diaz/master
Add Binary instance for Identity, from base-4.8.0.0
2 parents 6eedd64 + d67bc13 commit ecf48c4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Data/Binary/Class.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ import Data.Monoid (mempty)
6060
#endif
6161
import qualified Data.Monoid as Monoid
6262
import Data.Monoid ((<>))
63+
#if MIN_VERSION_base(4,8,0)
64+
import Data.Functor.Identity (Identity (..))
65+
#endif
6366
#if MIN_VERSION_base(4,9,0)
6467
import qualified Data.List.NonEmpty as NE
6568
import qualified Data.Semigroup as Semigroup
@@ -566,6 +569,12 @@ instance (Binary a, Binary b, Binary c, Binary d, Binary e,
566569
------------------------------------------------------------------------
567570
-- Container types
568571

572+
#if MIN_VERSION_base(4,8,0)
573+
instance Binary a => Binary (Identity a) where
574+
put (Identity x) = put x
575+
get = Identity <$> get
576+
#endif
577+
569578
instance Binary a => Binary [a] where
570579
put = putList
571580
get = do n <- get :: Get Int

0 commit comments

Comments
 (0)