Commit d27f1e78 authored by Gianfranco Costamagna's avatar Gianfranco Costamagna

haskell-protobuf: fixes builf failures with new ghc, from Steve Langasek and upstream

parent c97c5ec0
haskell-protobuf (0.2.1.1-4) UNRELEASED; urgency=medium
[ Clint Adams ]
* Set Rules-Requires-Root to no.
[ Steve Langasek ]
* d/p/0001-Fix-compilation-on-GHC-8.0.patch,
d/p/0002-Fix-tests-compilation.patch: cherry-pick from upstream to fix
compilation with ghc 8.2. Closes: #895612.
-- Clint Adams <clint@debian.org> Sun, 06 May 2018 22:10:23 -0400
haskell-protobuf (0.2.1.1-3) unstable; urgency=medium
......
From 0689cb6f0e5e980cb85e89eac53fa4fdb968b9ee Mon Sep 17 00:00:00 2001
From: YoEight <yo.eight@gmail.com>
Date: Wed, 16 May 2018 17:05:11 +0200
Subject: [PATCH 1/3] Fix compilation on GHC >= 8.0
---
protobuf.cabal | 3 +++
src/Data/Binary/Builder/Sized.hs | 6 +++++-
src/Data/ProtocolBuffers/Message.hs | 8 ++++++--
src/Data/ProtocolBuffers/Types.hs | 28 ++++++++++++++++------------
4 files changed, 30 insertions(+), 15 deletions(-)
Index: haskell-protobuf-0.2.1.1/protobuf.cabal
===================================================================
--- haskell-protobuf-0.2.1.1.orig/protobuf.cabal
+++ haskell-protobuf-0.2.1.1/protobuf.cabal
@@ -58,6 +58,9 @@
ghc-options:
-Wall
+ if impl(ghc < 8.0)
+ build-depends: semigroups == 0.18.*
+
-- executable protoc-gen-hs
-- default-language:
-- Haskell2010
Index: haskell-protobuf-0.2.1.1/src/Data/ProtocolBuffers/Message.hs
===================================================================
--- haskell-protobuf-0.2.1.1.orig/src/Data/ProtocolBuffers/Message.hs
+++ haskell-protobuf-0.2.1.1/src/Data/ProtocolBuffers/Message.hs
@@ -17,10 +17,11 @@
import Control.Applicative
import Control.DeepSeq (NFData(..))
import Data.Foldable
-import Data.Monoid
+import Data.Monoid hiding ((<>))
import Data.Serialize.Get
import Data.Serialize.Put
import Data.Traversable
+import Data.Semigroup (Semigroup(..))
import GHC.Generics
import GHC.TypeLits
@@ -96,9 +97,12 @@
newtype Message m = Message {runMessage :: m}
deriving (Eq, Foldable, Functor, Ord, Show, Traversable)
+instance (Generic m, GMessageMonoid (Rep m)) => Semigroup (Message m) where
+ Message x <> Message y = Message . to $ gmappend (from x) (from y)
+
instance (Generic m, GMessageMonoid (Rep m)) => Monoid (Message m) where
mempty = Message . to $ gmempty
- Message x `mappend` Message y = Message . to $ gmappend (from x) (from y)
+ mappend = (<>)
instance (Decode a, Monoid (Message a), KnownNat n) => GDecode (K1 i (Field n (RequiredField (Always (Message a))))) where
gdecode = fieldDecode (Required . Always)
Index: haskell-protobuf-0.2.1.1/src/Data/ProtocolBuffers/Types.hs
===================================================================
--- haskell-protobuf-0.2.1.1.orig/src/Data/ProtocolBuffers/Types.hs
+++ haskell-protobuf-0.2.1.1/src/Data/ProtocolBuffers/Types.hs
@@ -29,7 +29,8 @@
import Control.DeepSeq (NFData)
import Data.Bits
import Data.Foldable as Fold
-import Data.Monoid
+import Data.Monoid hiding ((<>))
+import Data.Semigroup (Semigroup(..))
import Data.Traversable
import Data.Typeable
@@ -38,25 +39,25 @@
-- |
-- 'Value' selects the normal/typical way for encoding scalar (primitive) values.
newtype Value a = Value {runValue :: a}
- deriving (Bounded, Eq, Enum, Foldable, Functor, Monoid, Ord, NFData, Show, Traversable, Typeable)
+ deriving (Bounded, Eq, Enum, Foldable, Functor, Semigroup, Monoid, Ord, NFData, Show, Traversable, Typeable)
-- |
-- 'RequiredField' is a newtype wrapped used to break overlapping instances
-- for encoding and decoding values
newtype RequiredField a = Required {runRequired :: a}
- deriving (Bounded, Eq, Enum, Foldable, Functor, Monoid, Ord, NFData, Show, Traversable, Typeable)
+ deriving (Bounded, Eq, Enum, Foldable, Functor, Semigroup, Monoid, Ord, NFData, Show, Traversable, Typeable)
-- |
-- 'OptionalField' is a newtype wrapped used to break overlapping instances
-- for encoding and decoding values
newtype OptionalField a = Optional {runOptional :: a}
- deriving (Bounded, Eq, Enum, Foldable, Functor, Monoid, Ord, NFData, Show, Traversable, Typeable)
+ deriving (Bounded, Eq, Enum, Foldable, Functor, Semigroup, Monoid, Ord, NFData, Show, Traversable, Typeable)
-- |
-- 'RepeatedField' is a newtype wrapped used to break overlapping instances
-- for encoding and decoding values
newtype RepeatedField a = Repeated {runRepeated :: a}
- deriving (Bounded, Eq, Enum, Foldable, Functor, Monoid, Ord, NFData, Show, Traversable, Typeable)
+ deriving (Bounded, Eq, Enum, Foldable, Functor, Semigroup, Monoid, Ord, NFData, Show, Traversable, Typeable)
-- |
-- Fields are merely a way to hold a field tag along with its type, this shouldn't normally be referenced directly.
@@ -64,7 +65,7 @@
-- This provides better error messages than older versions which used 'Data.Tagged.Tagged'
--
newtype Field (n :: Nat) a = Field {runField :: a}
- deriving (Bounded, Eq, Enum, Foldable, Functor, Monoid, Ord, NFData, Show, Traversable, Typeable)
+ deriving (Bounded, Eq, Enum, Foldable, Functor, Semigroup, Monoid, Ord, NFData, Show, Traversable, Typeable)
-- |
-- To provide consistent instances for serialization a 'Traversable' 'Functor' is needed to
@@ -74,9 +75,12 @@
newtype Always a = Always {runAlways :: a}
deriving (Bounded, Eq, Enum, Foldable, Functor, Ord, NFData, Show, Traversable, Typeable)
+instance Semigroup (Always a) where
+ _ <> y = y
+
instance Monoid (Always a) where
mempty = error "Always is not a Monoid"
- mappend _ y = y
+ mappend = (<>)
-- |
-- Functions for wrapping and unwrapping record fields.
@@ -175,24 +179,24 @@
-- |
-- 'Enumeration' fields use 'Prelude.fromEnum' and 'Prelude.toEnum' when encoding and decoding messages.
newtype Enumeration a = Enumeration {runEnumeration :: a}
- deriving (Bounded, Eq, Enum, Foldable, Functor, Ord, Monoid, NFData, Show, Traversable, Typeable)
+ deriving (Bounded, Eq, Enum, Foldable, Functor, Ord, Semigroup, Monoid, NFData, Show, Traversable, Typeable)
-- |
-- A 'Traversable' 'Functor' used to select packed sequence encoding/decoding.
newtype PackedField a = PackedField {runPackedField :: a}
- deriving (Eq, Foldable, Functor, Monoid, NFData, Ord, Show, Traversable, Typeable)
+ deriving (Eq, Foldable, Functor, Semigroup, Monoid, NFData, Ord, Show, Traversable, Typeable)
-- |
-- A list that is stored in a packed format.
newtype PackedList a = PackedList {unPackedList :: [a]}
- deriving (Eq, Foldable, Functor, Monoid, NFData, Ord, Show, Traversable, Typeable)
+ deriving (Eq, Foldable, Functor, Semigroup, Monoid, NFData, Ord, Show, Traversable, Typeable)
-- |
-- Signed integers are stored in a zz-encoded form.
newtype Signed a = Signed a
- deriving (Bits, Bounded, Enum, Eq, Floating, Foldable, Fractional, Functor, Integral, Monoid, NFData, Num, Ord, Real, RealFloat, RealFrac, Show, Traversable, Typeable)
+ deriving (Bits, Bounded, Enum, Eq, Floating, Foldable, Fractional, Functor, Integral, Semigroup, Monoid, NFData, Num, Ord, Real, RealFloat, RealFrac, Show, Traversable, Typeable)
-- |
-- Fixed integers are stored in little-endian form without additional encoding.
newtype Fixed a = Fixed a
- deriving (Bits, Bounded, Enum, Eq, Floating, Foldable, Fractional, Functor, Integral, Monoid, NFData, Num, Ord, Real, RealFloat, RealFrac, Show, Traversable, Typeable)
+ deriving (Bits, Bounded, Enum, Eq, Floating, Foldable, Fractional, Functor, Integral, Semigroup, Monoid, NFData, Num, Ord, Real, RealFloat, RealFrac, Show, Traversable, Typeable)
From 904fbe1f964436dc525cb0ac2d85587977534cea Mon Sep 17 00:00:00 2001
From: YoEight <yo.eight@gmail.com>
Date: Wed, 16 May 2018 17:05:37 +0200
Subject: [PATCH 2/3] Fix tests compilation
---
tests/Main.hs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/Main.hs b/tests/Main.hs
index a6b1b01..569a90f 100644
--- a/tests/Main.hs
+++ b/tests/Main.hs
@@ -13,7 +13,7 @@
{-# OPTIONS_GHC -fno-warn-orphans #-}
import Test.QuickCheck
-import Test.QuickCheck.Property
+import Test.QuickCheck.Property hiding (testCase)
import Test.Tasty
import Test.Tasty.HUnit
import Test.Tasty.QuickCheck
--
2.17.0
0001-Fix-compilation-on-GHC-8.0.patch
0002-Fix-tests-compilation.patch
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment