alphaHeavy / protobuf

An implementation of Google's Protocol Buffers in Haskell.
http://hackage.haskell.org/package/protobuf
BSD 3-Clause "New" or "Revised" License
95 stars 18 forks source link

encode/decode messages within messages? #23

Closed mitchellwrosen closed 9 years ago

mitchellwrosen commented 9 years ago

What's the recommended way of deriving Encode/Decode instances for messages that are built from other messages? The straightforward standalone deriving doesn't quite work, because it requires an EncodeWire/DecodeWire instance:

data Foo = Foo (Required 1 (Value Bar))
  deriving (Generic, Show)
instance Encode Foo -- No instance for EncodeWire Bar

data Bar = Bar (Required 1 (Value Text))
  deriving (Generic, Show)
instance Encode Bar
NathanHowell commented 9 years ago

I believe you want to use Message instead of Value. On Oct 5, 2015 3:51 PM, "Mitchell Rosen" notifications@github.com wrote:

What's the recommended way of deriving Encode/Decode instances for messages that are built from other messages? The straightforward standalone deriving doesn't quite work, because it requires an EncodeWire/DecodeWire instance:

data Foo = Foo (Required 1 (Value Bar)) deriving (Generic, Show)instance Encode Foo -- No instance for EncodeWire Bar data Bar = Bar (Required 1 (Value Text)) deriving (Generic, Show)instance Encode Bar

— Reply to this email directly or view it on GitHub https://github.com/alphaHeavy/protobuf/issues/23.

mitchellwrosen commented 9 years ago

Oh! Didn't see that =) Thanks!

NathanHowell commented 9 years ago

No problem :) On Oct 5, 2015 3:54 PM, "Mitchell Rosen" notifications@github.com wrote:

Oh! Didn't see that =) Thanks!

— Reply to this email directly or view it on GitHub https://github.com/alphaHeavy/protobuf/issues/23#issuecomment-145691712.