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

Unique OCaml module for all messages #63

Open
lambdaxdotx opened this issue Jul 2, 2024 · 1 comment
Open

Unique OCaml module for all messages #63

lambdaxdotx opened this issue Jul 2, 2024 · 1 comment

Comments

@lambdaxdotx
Copy link

Hi,
Thanks for your work on this project.

This is a feature request more than an actual issue.

tldr: Would it be possible to modify the OCaml generation to optionally emit a single OCaml module for all messages in a .proto file rather than a separate module for each of the messages?

A more reasoned request follows. Messages can be structured to follow a hierarchy, as in this example:

message A {
  bool is_something = 1;
  repeated B bs = 2;
}

message B {
  bool is_something_else = 1;
  oneof content {
    C c = 2;
    D d = 3;
  }
}

message C { ... }
message D { ... }

Especially in such cases, it would be useful to optionally have in output just an OCaml module with a type mirroring such a hierarchy, approximately of the form:

type a = {
  is_something: bool;
  bs: b list;
}

and b = {
  is_something_else: bool;
  content: [ `not_set | `C of c | `D of d ];
} 

and c = { ... }
and d = {....}

Such an OCaml type hierarchy allows for easier navigation of the type structure than the current one. In particular, it would be easier to write a ppx for doing something on such a solution than the current one.

Does this sound reasonable? How hard would it be to make such a change?

@andersfugmann
Copy link
Contributor

Please note that active development of the ocaml-protoc-plugin has moved to https://github.com/andersfugmann/ocaml-protoc-plugin. I have replied to your question here: andersfugmann/ocaml-protoc-plugin#42.

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

2 participants