proto3-suite icon indicating copy to clipboard operation
proto3-suite copied to clipboard

Configurable proto module prefix

Open tim2CF opened this issue 4 years ago • 4 comments

At the moment compile-proto-file executable inherits haskell module namespace from protobuf package namespace. It might be very handy to being able to customize haskell module prefix to avoid namespace conflicts in cases where multiple protobuf APIs/repos/submodules are used in one haskell project.

tim2CF avatar Mar 30 '21 15:03 tim2CF

In general, one way to do this would be via an option directive near the top of the file. What I might suggest is something like an option haskell_module that lets you customize the generated Haskell module name.

Gabriella439 avatar Mar 30 '21 16:03 Gabriella439

This is ok way to do so, and conceptually correct from Google Protobuf standard point of view. In general case Google is promoting custom options for language-specific details. It's unrelated, but options also might be useful for automated wrapping-unwrapping newtypes - protobuf typing in general is poor, for example UTCTime probably will be represented as uint64 in protobuf type system, but then we can specify Haskell rich UTCTime type as an option for the field and automate parsing this way using classes or something like this.

tim2CF avatar Mar 31 '21 09:03 tim2CF

Btw I don't see any Haskell related codes here. If we do any sort of custom options - it's nice to register in this registry

tim2CF avatar Mar 31 '21 09:03 tim2CF

But option for compile-proto-file executable might be very handy as well (and I think relatively easy to do). In our particular use case we have ~200 protobuf files, and adding new custom option to every file might be not the best experience

tim2CF avatar Mar 31 '21 09:03 tim2CF