-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add CQG CMS API protobuf Haskell package #1
Conversation
This script will download the CQG CMS API protobuf files, and use them to generate Haskell modules.
library | ||
exposed-modules: | ||
Proto.CMS.ApiLimit1 | ||
Proto.CMS.ApiLimit1_Fields | ||
Proto.CMS.Cmsapi1 | ||
Proto.CMS.Cmsapi1_Fields | ||
Proto.CMS.Common1 | ||
Proto.CMS.Common1_Fields | ||
Proto.CMS.Location1 | ||
Proto.CMS.Location1_Fields |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having these Haskell modules all be named Proto.*
feels somewhat unfortunate. It feels like it would be better if we could name them something like CQG.Proto.CMS.ApiLimit1
, but it doesn't appear that the proto-lens
library has any way of generating modules with a different naming scheme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds like it would pretty straightforward to rename the modules as part of running generate.sh
. I agree that we should put them into the namespace that we want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, how do you feel about formatting the code as part of generation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds like it would pretty straightforward to rename the modules as part of running generate.sh
I imagine we could do this with some mv
s and sed
s, but it would be something we might have to fiddle with again in the future when upgrading the proto-lens
version. I'm also not sure how big of an advantage it would be.
I'm imagining we have this cqg-cms-api-proto
library, which just contains the generated Haskell modules, like in this PR.
And then we have a separate library like cqg-cms-api-client
, which contains the higher-level functions, intended for use by end-users (which in this case, would be our FCM libraries in the bitnomial
repo).
Right now, my plan is to set up the cqg-cms-api-client
package so it is fully-usable as-is, and re-exports everything necessary from the cqg-cms-api-proto
library. So end-users wouldn't have to touch the cqg-cms-api-proto
library at all, it would just be an internal implementation detail.
As long as end-users don't have to directly use cqg-cms-api-proto
, I imagine it would be fine to leave the module names as Proto.CMS.*
and Proto.Common.*
.
how do you feel about formatting the code as part of generation?
I think this would be relatively straightforward to add, but:
- The generated code is so verbose that it is pretty hard to read. I don't think that a different formatting style would make it much easier.
- In my experience,
proto-lens
follows a pretty good pattern, so the generated protobuf Haskell modules are pretty easy to use once you get the hang ofproto-lens
. In practice it feels easier to look at the haddocks or the underlying.proto
files (as opposed to the source of the generated Haskell files). - It appears that the generated code at least has a consistent formatting (even if it is not the formatting style we normally use).
This PR adds an initial
cqg-cms-api-proto
Haskell package. This package contains Haskell modules generated from the CQG CMS API protobuf files.This is currently using the
proto-lens
functionality for manually generating Haskell modules from the protobuf files: https://github.com/google/proto-lens/tree/master?tab=readme-ov-file#manually-running-the-protocol-compilerMost of the commits in this PR won't be too interesting to review, but the downloading and generation script may be slightly interesting to review (
cqg-cms-api-proto/generate.sh
).