Skip to content
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

Unable to model protobuf's "oneof" when generating a proto file from types #256

Open
gurgl opened this issue Oct 21, 2024 · 0 comments
Open

Comments

@gurgl
Copy link

gurgl commented Oct 21, 2024

Even if I searched the repository extensively I couldn't find anything that hints you can do this. The function https://hackage.haskell.org/package/proto3-suite-0.7.0/docs/src/Proto3.Suite.Class.html#message seems to indicate all message fields are constructed using DotProtoMessagePart's with constructor DotProtoMessageField DotProtoField.

I got the impression you should wrap your messages oneof field type in ForceEmit a, but it seems they only accept Primitive a.

I might be rambling here, but this is my take away from digesting the code a bit. If anyone, with insight into the code, think there is a chance to make it possible to model oneof's containing toplevel messages using the current generics based approach (genericDotProto) I could try to champion it with some guidance. I mean accomplishing the below sketchy example

-- MessageX below would map to proto top level messages.

data Message1 = Message1 { fld1 :: OnOff  SumType1 }  

data SumType1 = A Message2 | B 

data Message2 = Message2 { fld1 ::  NestedVec Message3 }  

data Message3 = Message3 { fld1 ::  Int32  }  

that would translate into a .proto like (mind my .proto knowledge is very limited)

message Message1 {
  oneof fld1 {
    string b = 1;
    Message2 a = 2;
  }
}

message Message2 {
  repeated Message3 fld1 = 1;
}

message Message3 {
  unsigned fld1 = 1;
}

@gurgl gurgl changed the title Uable to model protobufs "oneof" when generating a proto file Unable to model protobuf's "oneof" when generating a proto file from types Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant