froto
froto copied to clipboard
Add support for DUs
Hi, I didn't find any sample on that one, but would be nice to have serialization of Discriminated Unions
I don't think this is in scope for froto as it stands. Im also assuming you mean oneOf types. I have a custom solution to this where the code from froto.parser/serialiser is used with a custom code generator to produce F# record/unions. Its doubtful I could fold this back into this solution as it uses parse tree generation rather than the .Net 1 era generation of type providers which is pretty poor.
@7sharp9 I have a renewed interest in actually making a froto
.NET global tool that can do the code generation #15, especially if it will lead to gRPC generation eventually #90. I think we may have to boot the type provider code back out if it is not going to be maintained #76. It would be nice if it was maintained, but I'm not interested in it personally. cc @takemyoxygen
@ctaggart I still hope I will work on the type provider improvements at some point but it's not my priority at the moment. I guess, extracting the type provider back into a separate repository is the best way to go - you will be able to focus on code generation and maybe at some point I will catch up with the type provider.
@takemyoxygen Or just add it back here when you have time. I'm fine either way.
@ctaggart Thats actually what I did, except Im using froto.parser to parse the proto3 file, then using proto.serializer along with quite a lot of the type provider code. Some of it is heavily modified, I also added DU generation for the oneOf fields.
The big difference is Im not using any of the type provider mechanism just the provided type structure and quotations as a basis of creating an ast, which is then written to a .fs file.
@7sharp9 Yes, that is what I want. Any chance you are going to add a PR with that work?
@ctaggart Its been talked about, I would like to rework more of the quotation parts as they struggle with representing F# without loosing too much information, like infix/prefix on operator calls and also no pattern matching as its removed by the quotation translator.
Pretty soon the oneOf
code will be open source but its entirely a code generator rather than a type provider, it shares a similar implementation, I used the type provider code as reference but changed a lot of it and added further pieces to it.
I like code generators. Looking forward to seeing it.
https://twitter.com/7sharp9_exhumed/status/1043155315112460289
https://github.com/jet/falanx