-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
schema-schema codegen demo now includes unmarshal exercise #76
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
warpfork
added a commit
to ipld/specs
that referenced
this pull request
Sep 6, 2020
There are several here at once: - All the unions are now keyed. Previously TypeDefn and TypeDefnInline were using "inline" representation. This results in most of the diff (it changes the indentation of quite a few things). - There's now a "Unit" type in play. The definition of this can be approximated by an empty struct -- the semiotic is that it must have a cardinality of one. We need to add this concept of the schema system. (I think I've mentioned this elsewhere, but if not, now it's mentioned!) - Enums are specified using the 'Unit' type. Which means serially, they now have `{}` inside them instead of `null`. This might be a temporary change: it's a consequence of the idea to emulate Unit by use of an empty struct, and if we give "unit" its own kind, we could give it its own selection of representation strategies (which could then include a choice of a representation like "null"). There are also some renames which I felt improved clarity: - Type -> TypeDefn - InlineDefn -> TypeDefnInline - TypeTerm -> TypeNameOrInlineDefn This has been exercised and developed in the process of working on ipld/go-ipld-prime#76 -- which may explain why it was "necessary" to make some changes such as those to enums (doing so let us actually do a full parse of this data!).
warpfork
added a commit
to ipld/specs
that referenced
this pull request
Sep 6, 2020
There are several here at once: - All the unions are now keyed. Previously TypeDefn and TypeDefnInline were using "inline" representation. This results in most of the diff (it changes the indentation of quite a few things). - There's now a "Unit" type in play. The definition of this can be approximated by an empty struct -- the semantic is that it must have a cardinality of one. We need to add this concept of the schema system. (I think I've mentioned this elsewhere, but if not, now it's mentioned!) - Enums are specified using the 'Unit' type. Which means serially, they now have `{}` inside them instead of `null`. This might be a temporary change: it's a consequence of the idea to emulate Unit by use of an empty struct, and if we give "unit" its own kind, we could give it its own selection of representation strategies (which could then include a choice of a representation like "null"). There are also some renames which I felt improved clarity: - Type -> TypeDefn - InlineDefn -> TypeDefnInline - TypeTerm -> TypeNameOrInlineDefn This has been exercised and developed in the process of working on ipld/go-ipld-prime#76 -- which may explain why it was "necessary" to make some changes such as those to enums (doing so let us actually do a full parse of this data!).
mvdan
approved these changes
Sep 7, 2020
- it now uses kinded unions (since those are supported now; they weren't yet the last time we touched this demo!). - a few typos are fixed (field names; in one case, a place that must support type names as well as inline defns). - added the 'Schema' type at the very top! this is what parsing the schema-schema starts with!
This is a somewhat altered schema-schema document, as commented. Some of those alterations might get upstreamed; I'll be making other PRs to the upstream specs repo to discuss that.
… the programatic type construction. The gap between these isn't within the reach of this test to probe. (Yet. We'll get there. It's not terribly much further.)
warpfork
force-pushed
the
schema-schema-exercise
branch
from
September 10, 2020 11:58
812202f
to
2b7b3f0
Compare
warpfork
added a commit
to ipld/specs
that referenced
this pull request
Apr 11, 2021
There are several here at once: - All the unions are now keyed. Previously TypeDefn and TypeDefnInline were using "inline" representation. This results in most of the diff (it changes the indentation of quite a few things). - There's now a "Unit" type in play. The definition of this can be approximated by an empty struct -- the semantic is that it must have a cardinality of one. We need to add this concept to the schema system. (I think I've mentioned this elsewhere, but if not, now it's mentioned!) - Enums are specified using the 'Unit' type. Which means serially, they now have `{}` inside them instead of `null`. This might be a temporary change: it's a consequence of the idea to emulate Unit by use of an empty struct, and if we give "unit" its own kind, we could give it its own selection of representation strategies (which could then include a choice of a representation like "null"). There are also some renames which I felt improved clarity: - Type -> TypeDefn - InlineDefn -> TypeDefnInline - TypeTerm -> TypeNameOrInlineDefn This has been exercised and developed in the process of working on ipld/go-ipld-prime#76 -- which may explain why it was "necessary" to make some changes such as those to enums (doing so let us actually do a full parse of this data!).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Like it says on the tin: there's now a test which exercises unmarshalling the schema-schema into the codegen'd types we made to represent the schema types.
First there were some minor fixups to the instructions to the codegen (which are still expressed in our placeholder golang constructors):
Then, rigging up the unmarshal of the schema-schema json is... pretty trivial, really. (Goal success!)
There are also some alterations to the schema-schema json I've made here. You can find comments about this in the diff body. Some of these changes may turn into PRs upstream to the schema-schema document in the specs repo.