Closed IvantheTricourne closed 4 years ago
I've already tried to do this once. You're going to run into a problem because the library is trying to support messages coming from protolens as well.
when you write instances of the form Foo a => Bar a
, you will run into overlapping and undecidable instances.
@blinky3713 I got around undecidable instances by directly implementing default
s in the HasCodec
class.
default encode :: Message a => a -> BS.ByteString
default decode :: Message a => BS.ByteString -> Either Text a
I did this over trying to write an instance for Message a => HasCodec a
, which is an undecidable instance.
It's a bit weird (i.e., because not all instances of HasCodec
necessarily refer to a proto3-suite message), but I feel like proto3-suite
messages are good to default on since these already have their own codecs.
Any type that has a
Proto3.Suite.Message
instance should have a defaultHasCodec
instance (i.e., using the codecs fromProto3.Suite
).This alleviates the need to repeatedly do this