Compatible Schema Updates
Closed this issue · 2 comments
I have been working on generics for my biparsing package and have been trying to think of a way to ensure compatible updates (adding a field, constructor, ect. to a type) to a schema so that breaking changes cannot be introduced. Have you thought of this?
Schema versioning is a pretty wide topic. e.g. JSON can read fields in any order and add new optional fields while retaining backwards compatibility. That's harder in a binary schema, but projects such as Cap'N Proto and BSON have well-tested approaches that may be of interest. fumieval's winery Haskell library may also be interesting.
Consider exploiting the fact that constructors and named fields must have unique names in a given Haskell data type. Indeed, Binrep.Generic.nullTermCstrPfxTag tells the generics to use the constructor name in UTF-8 as a prefix. But we can't do the same for fields (i.e. prefixing with the field name), because direct left-right field sequencing is an important design feature.
By the way, interesting library! I've settled on very "light" biparsing for my uses, where parsing and serializing definitions remain separate (even though they should have round trip isomorphism). It means the programmer must remain vigilant when writing instances, but we have a much better time with performance and code simplicity (I'm not envious of your type signatures!).
Closing as not planned (but feel free to continue discussion here or on your repo).
Thanks, I have been trying to improve the type signature complexity with biparsing-mixes which handles the common cases. I have created a few examples using these
https://github.com/BebeSparkelSparkel/biparsing/tree/examples/examples
examples/ProductAndSum.hs is the easiest to understand.