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

Generic runtime representation #397

Open
tim2CF opened this issue Aug 27, 2020 · 2 comments
Open

Generic runtime representation #397

tim2CF opened this issue Aug 27, 2020 · 2 comments

Comments

@tim2CF
Copy link

tim2CF commented Aug 27, 2020

Hello! Is there some sort of generic runtime representation of protobuf types generated from protobuf files? Something similar to this (but for protobuf) https://hackage.haskell.org/package/aeson-1.5.3.0/docs/Data-Aeson.html#t:Value

@judah
Copy link
Collaborator

judah commented Aug 29, 2020

The Message instance is probably the closest thing to what you're asking. For each type we generate fieldsByTag and fieldsByName which let you walk through a proto value using type-safe reflection. You can look at proto-lens-arbitrary for an example how to use it:
http://hackage.haskell.org/package/proto-lens-arbitrary-0.1.2.9/docs/src/Data.ProtoLens.Arbitrary.html#arbitraryMessage

@tim2CF
Copy link
Author

tim2CF commented Aug 31, 2020

Thanks for reply, @judah !
I see, there is type-related information like this
http://hackage.haskell.org/package/proto-lens-arbitrary-0.1.2.9/docs/src/Data.ProtoLens.Arbitrary.html#arbitraryScalarValue
I mean Int32Field, Int64Field, UInt32Field etc. This is great, but this information is segregated from runtime values. Is there something similar to runtime AST (like in Aeson)? I want to recursively foldr real message with real values in generic way, and looking for something like

data ScalarValue = Int32Value Int32 | Int64Value Int64 | BytesValue ByteString | ... etc

And similar runtime AST for composite types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants