froto icon indicating copy to clipboard operation
froto copied to clipboard

Add support for DUs

Open tjaskula opened this issue 7 years ago • 10 comments

Hi, I didn't find any sample on that one, but would be nice to have serialization of Discriminated Unions

tjaskula avatar May 09 '17 09:05 tjaskula

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 avatar Jul 02 '18 12:07 7sharp9

@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 avatar Jul 02 '18 16:07 ctaggart

@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 avatar Jul 02 '18 18:07 takemyoxygen

@takemyoxygen Or just add it back here when you have time. I'm fine either way.

ctaggart avatar Jul 03 '18 01:07 ctaggart

@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 avatar Jul 03 '18 11:07 7sharp9

@7sharp9 Yes, that is what I want. Any chance you are going to add a PR with that work?

ctaggart avatar Jul 03 '18 14:07 ctaggart

@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.

7sharp9 avatar Jul 03 '18 14:07 7sharp9

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.

7sharp9 avatar Aug 29 '18 13:08 7sharp9

I like code generators. Looking forward to seeing it.

ctaggart avatar Aug 31 '18 00:08 ctaggart

image

https://twitter.com/7sharp9_exhumed/status/1043155315112460289

https://github.com/jet/falanx

ctaggart avatar Sep 22 '18 23:09 ctaggart