Open vil1 opened 5 years ago
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).
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 containIso
s (namelyRecordSchema
,Union
,SeqSchema
, etc.) aren't, sinceIso
s 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.