schemaz icon indicating copy to clipboard operation
schemaz copied to clipboard

Generic derivation of schemas

Open vil1 opened this issue 6 years ago • 4 comments

Building upon #47, it seems rather obvious that we should be able to automatically derive the schema of any ADT at compile time (as a matter of fact, this gist achieves just that, using shapeless).

Like to #47, this should be provided in the generic (sbt) module, with no impact on the existing API for constructing schemas.

Also, if #34 gets merged before this issue is solved, words must be added in the documentations to stress out the fact that such fully automatic derivation should be used with caution, for it somehow defeats the purpose of having schemas as runtime values (in scenarios where schema evolution is a needed feature, it OK to fully derive schemas at compile time, as long as the application stores the derived schema somewhere at runtime).

vil1 avatar Jan 20 '19 22:01 vil1

@vil1, Had a discussion with @GrafBlutwurst about the gist code you shared in the issue for understanding. I will modify this gist code to align with latest schema encoding and raise a PR to take it forward.

sasiharan avatar Jan 28 '19 08:01 sasiharan

@sasiharan that's great news!

FTR, the mentioned gist is here

Please note that it might be easier to first work on #47 and then use that work to solve this issue (that is, the stuff around the Constructor typeclass in the gist).

Also, I'd prefer we use scalaz-deriving for this instead of shapeless for our generic derivation mechanisms. I'm not yet knowledgeable with it to be able to give you any guidance, but I intend to learn more about it soon (and I can also bring in people who know it well).

vil1 avatar Jan 28 '19 21:01 vil1

Agreed that #44 and #47 needs to be addressed before working on this issue. I will also go through scalaz-deriving and see how we can achieve auto derivation of Isos and Schemas.

sasiharan avatar Jan 29 '19 14:01 sasiharan

Don't worry too much about #44 though, it might take a while to be solved. And if it ever has an impact on your work, I'll take care of it as much as possible.

vil1 avatar Jan 29 '19 21:01 vil1