Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR introduces some experimental utilities for defining runtime-checkable data schemas. It's a small step towards Cambria. It uses @effect/schema as a toolkit for defining schemas that can be runtime-checked, automatically turned into TS types, and transformed into one another.
The current rough plan is to try incubating these simple utilities within TEE and then perhaps pull them out into a reusable library if it seems useful.
The basic workflow: you have a doc URL, a schema (defined in Effect), and a component you want to use to display the document. Then you just pass them into a
withDocument
higher-order component:The outer wrapper component handles loading the document and checking whether its schema matches what's expected. It also renders simple UI: a loading screen, and an error+repair screen if the doc can't be parsed as the expected schema.
CleanShot.2024-01-04.at.17.13.40.mp4
The inner component (in this case,
TinyEssayEditor
) gets the following benefits: it's only rendered once the data is actually loaded and has been verified to fit the expected schema. This means no loading states or shotgun parsing in the inner component.Ongoing work / open questions