Comments (10)
Hi Gavin, I'm actually making some changes to the code generation that should make it easier to support proto2 syntax, at least in principle. The main issue is that proto2 does not have a canonical JSON representation AFAICT (though I might have missed it), so so things like unset vs default fields and default enum values are slightly more vague there. Having worked with both proto2 and proto3, I came to appreciate proto3 simplicity and streamlined semantics, so I would personally advise you to consider migrating to proto3 for your projectsi at all possible. If your project is open source, feel free to post a link so i may take a look perhaps
from elm-protobuf.
It is in fact! It's Cockatrice. The proto files are here
from elm-protobuf.
Thanks, interesting project! I see you use quite advanced features such as extensions, which I would realistically not expect to ever support in this library to be honest. In proto3, you would have to use the Any type to achieve something similar, but on the other hand if you don't really expect other clients to extend your photos, you may as well inline them as regular fields in the base message. That's really up to you though, even if you did switch to use proto3, I still don't have a concrete plan on how to support it in elm in an idiomatic way. Suggestions are welcome though :)
from elm-protobuf.
I expect some nested ADTs would need to be generated, like type AllMessages = TypeOne | TypeTwo
, type TypeOne = TypeOneA | TypeOneB
, and so on.
from elm-protobuf.
so so things like unset vs default fields and default enum values are slightly more vague there
I'm looking for proto2 support because the way proto3 treats defaults, i.e., you cannot tell a value is unset of it happens to be set to the default value, this basically makes Maybe a
useless, I think the one who designed proto3 designed it this way because he don't use ADT a lot, and they, those who use imperative languages, have null problems, so they think they can get away with a default value.
Maybe we can add some additional markers, like int32 a = 1 [optional = true]
, then the generated elm type for this filed would be a : Maybe Int
.
from elm-protobuf.
@qwfy you can use well known types such as IntValue
for that, and they should be translated into the corresponding Maybe
type in elm. Let me know if you have any issue with that.
from elm-protobuf.
I am currently using this, the problem with the so called well known types (well known for what? amending a bad design?) is that they are not well supported, I have to manually box/unbox it on the other side.
Maybe instead of supporting a broken design, we support something better.
All said, I do appreciate your work.
from elm-protobuf.
I think "well known" refers to the fact that the proto compiler may treat them specially (which my elm implementation does). What language are you using on the other side? It seems like a possible fix would be to support such special implementation there too. Would that be reasonable?
from elm-protobuf.
The other side is OCaml, and the compiler is ocaml-protoc (it's a standalone compiler, not a plugin to the protoc
binary).
from elm-protobuf.
If the biggest issue with supporting proto2 syntax is JSON representation, I may be able to help. The canonical protoc plugin for Scala was developed at my company and we reuse it very extensively ( binary format within the backed, and JSON between backend and frontend ). I'd love to work with you to develop the appropriate semantics. It's really not that different at all from proto3 semantics.
from elm-protobuf.
Related Issues (11)
- infix functions in generated decoders HOT 2
- Elm 0.19 upgrade not working HOT 2
- Update Functions HOT 4
- support gRPC services HOT 6
- Update tags to support Go modules HOT 3
- Incorrect code generated with type names
- Map support HOT 7
- LIst of items not decoding HOT 1
- enum as int32 HOT 9
- name collisions HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elm-protobuf.