feat(schema): expose useful functions for building schemas #569
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.
Goals
fix #568
Implementation
add more minimal form of schema compilation and useful functions for merging one type system into another. this would enable the various types of schema type system building I discussed in #568.
Note that most of these functions have been written without access to private data members, in part cause until this is merged I'm just going to build on top. The absolute minimal version of this PR would simply make
spawnType
at https://github.com/ipld/go-ipld-prime/blob/master/schema/dmt/compile.go#L135 a public functionSpawnType
(just to avoid a large copy paste). Pretty much everything else could be built outside the library if you want to target the minimal form.However, one can see that some of the functions would probably be better with private members. Clone for example is not a full depth clone and only works on types that are in a typesystem, cause many of the public functions of various kinds of types return not the type names but actual types looked up from the TypeSystem.
Anyway, FYC, happy to modify to super minimal (i.e. just spawnType -> SpawnType to make it exported) to building a full incremental builder for type systems. Up to reviewer!