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

Schema serialisation #30

Open
vil1 opened this issue Jan 3, 2019 · 1 comment
Open

Schema serialisation #30

vil1 opened this issue Jan 3, 2019 · 1 comment

Comments

@vil1
Copy link
Member

vil1 commented Jan 3, 2019

Schemas must be readable at runtime. In other words, we must provide a way to read/write schemas from/to the wire.

Schemas composed only of One, :+: and :*: (so-called "essential schemas") are (almost) trivially serialisable. But schemas that contain Isos (namely RecordSchema, Union, SeqSchema, etc.) aren't, since Isos are – roughly – functions, and functions aren't trivially serialisable.

On the other hand, these "iso-based" GADT members are merely a way to build schemas for user-defined Scala classes, which is only a part of our intended use cases. We also want to provide a safe way to deal with "dynamic data", eg. processing JSON documents (or Avro records, etc.) at runtime without necessarily having to coerce them to a case class.

These "dynamic" use cases are the ones that are most likely to require schema serialisation, so providing a way to serialise "essential schemas" only sounds like an acceptable first step.

@vil1 vil1 mentioned this issue Jan 3, 2019
@vil1
Copy link
Member Author

vil1 commented Jan 18, 2019

So, after "brainstorming#2", we've decided to first try (de)serializing schemas while ignoring the "isos" (that can be found in Union, Record, IsoSchema).

This can be done by simply not writing the iso field of these classes, and put Iso.refl (the identity Iso) on the read side.

As a bonus, this could be done "automatically" by defining a schema for Schema and deriving codecs from it (eating our own dogfood).

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

1 participant