Protocol Buffers using bytes: `elm-protocol-buffers`

I’m very excited to see this! The API feels quite natural.

I decided to take a stab at writing a compiler plugin (https://github.com/adeschamps/protoc-gen-elm). I started by sending stdin/stdout across ports and handwriting a minimal subset of the types, decoders, and encoders from plugin.proto and descriptor.proto. I now have a protoc plugin that can read a CodeGeneratorRequest and generates a CodeGeneratorResponse by using https://package.elm-lang.org/packages/stil4m/elm-syntax/latest/ to construct and write an Elm syntax tree. It works for simple messages - there are still plenty of protobuf features that it doesn’t handle. I’m curious how much/little work would have to be done before it can generate the encoders and decoders that I was writing by hand.

Is your code generator available to contribute to? I haven’t put too much time into this yet, and if you already have something going then it would be nice to collaborate on that.

1 Like