Project Cambria: Translate your data with lenses
inkandswitch.com
inkandswitch.com
One initial thought that I'd offer is that in a simple running system, these 'lenses' are arranged into a series[1] that can take a datastructure from an origin 'base' version all the way through to the latest-known representation. This may be more familiar to most developers as an analogy to database migration scripts, as mentioned in the post.
When a new lens is created, the developers may want to distribute it to a subset of users, ensure that it works correctly, and potentially adjust it based on feedback before issuing the final lens to the application's population[2].
If this is the intended release workflow, then the arrangement of lenses becomes a graph or chain rather than a simple series. There may be times where it's necessary to backtrack briefly.
It's possible (although hacky, I will admit) to create an NPM JavaScript module that has another version of itself as a dependency.
I mention that because this provides a way to distribute some code -- a lens, for example -- alongside a dependency graph using an ecosystem that is relatively well-evolved (in terms of release management, client upgrade support, etc) for versioned code distribution.
[1] It's nice the that analogy with light passing through a series of lenses fits
[2] Think of an optician testing your eyesight and asking questions about various sample lenses
Are there applications for lenses that really allow lossless translation in both directions? Or am I misunderstanding the concept in some fundamental way?
In other words, you couldn't have a bijective function between an integer and a boolean, because there are fewer possible boolean values than integer values.
Demanding bijective functions is probably more restrictive than you want to be for building real-world systems. We discuss this a bit in the paper -- I think look for "convert".
We hesitated to mention database migrations too much in the essay for the reason you mention: in some sense, the whole point of Cambria is that you never do a one-time "migration", but rather you just continuously translate the data.
Still, using the system does feel pretty similar to doing database migrations, and we intentionally modeled some of the dev workflow after ActiveRecord migrations:
https://www.inkandswitch.com/cambria.html#developer-workflow
Their software is insane and I imagine part of this is about taking Muse to the web (at least a viewer).
Stoked!
App is at https://apps.apple.com/us/app/muse-tool-for-thought/id150156...
It looks interesting, but $100 per year is really steep
In other words, with Cambria you can build a graph of lenses that describe various data schemas and then translate from or to any of them.
That said, XSLT has different strengths (syntax-aside) in that it is a general purpose templating language with strong functional programming underpinnings.
Long run, I expect neither JSON nor YAML are really the best solutions.
This always ends up happening; this will happen here, without a doubt.
[1]: https://hitchdev.com/strictyaml/why/implicit-typing-removed/