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

How do you see the generated module names? #328

Open
mpdairy opened this issue Jul 12, 2019 · 3 comments
Open

How do you see the generated module names? #328

mpdairy opened this issue Jul 12, 2019 · 3 comments

Comments

@mpdairy
Copy link

mpdairy commented Jul 12, 2019

I have some complicated protos I'm trying to work with and would find it very helpful to see a list of the modules that are created from the proto files (or, at least, that would be created if I knew their names and could put them in exposed-modules). Is there some way to get a list of them?

@judah
Copy link
Collaborator

judah commented Jul 13, 2019

Unfortunately there isn't an automated way to get the names. It's probably something we could improve, for example as another flag to the proto-lens-protoc binary, or in the stderr of the setup script's output. We could also probably improve this in the documentation.

The logic is intentionally pretty simple:

-- | Get the Haskell module name corresponding to a given .proto file.

In short:

  • Each path component of the filepath gets turned from snake_case into CamelCase (dropping the .proto extension).
  • The primary module is those components together with ., plus a Proto. prefix.
  • There's also another (optional) module with _Fields appended.

So for example, foo/bar_baz.proto turns into Proto.Foo.BarBaz and Proto.Foo.BarBaz_Fields.

@mpdairy
Copy link
Author

mpdairy commented Jul 13, 2019

Ok, thanks. I was thinking the Proto prefix came from the proto folder, which led to much confusion.

Is it true that you can only run defaultMainGeneratingProtos "proto" once in Setup.hs? I was writing a program that translates messages between two sets of proto files, and was forced to put them all in the same proto folder, which works for now, but it would be nicer if I could keep them separate.

@judah
Copy link
Collaborator

judah commented Jul 13, 2019

Yes, currently it only allows a single "root" directory per project. Two possible workarounds are:

  • Create different Cabal libraries for the the different folders
  • Symlink the different folders into one common location (which would add an additional prefix component to the module names).

@judah judah added this to To do in Improve Documentation Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants