-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
oneof support #4
Comments
There are no such plans at the moment, but you are very welcome to submit a
PR implementing them!
|
I might be interested in implementing this. @k-bx could you give any pointers on how to go about implementing this, for someone unfamiliar with the codebase? Which parts would need to be modified? How much knowledge of the wire protocol will I need? Any guidance you could give would be appreciated |
@bitc great to know you'd be willing to give it a try! I'll be honest with you, I'm not familiar with codebase at all, I also don't know much about protobuf protocol. I took maintainership somewhat recently just to keep package alive (update dependencies, merge with fork etc.). So I think you'll be on your own here (if you'll feel comfortable with code-base, I'd be happy to make you a co-maintainer). But I will certainly do in-depth code-review when the feature is ready before merging it :) |
Any progress on this? If not, I might give it a try. I'm not very familiar with protocol buffers or this package, but from reading the spec I have an idea of what I think oneof should look like in Haskell. |
I am also very interested in oneof implementation, too! |
I've started implementing oneof on |
I started on this, but got a little stuck on how to represent oneofs in Reflections.hs Here's how I think oneofs might look in Haskell. Example:
This might (after #5 is implemented) generate something like:
and possibly also functions |
yes. that's the goal (using sum type in haskell to represent oneof). The original protobuf implementation for sum types is quite ugly (the fields in oneof has a oneof_index flag to specify which oneof it belongs to, i.e. it is not defined in tree-like structure, but as ownership graphs). Since we reuse descriptor.proto from the original protobuf library, we need to keep this structure somehow (at least, until parsing), so the reinterpretation as haskell sum type is not very transparent as it seems. I now think I figured out how to tackle this problem. It's a little aggressive change in the code base, though. |
I've succeeded in oneof implementation up to instance of TextMsg (textGet, textPut). Oneof is implemented as a sum type. Now I move on to final binary wire serialization! |
Binary (wire) encoding/decoding for oneof is implemented! Tested between haskell and C++ (code generated from |
Is there any planes to add oneof support?
The text was updated successfully, but these errors were encountered: