Skip to content
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
merged 6 commits into from
Sep 10, 2020

Conversation

warpfork
Copy link
Collaborator

@warpfork warpfork commented Sep 6, 2020

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):

  • 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) that were uncovered while lining up this test.
  • added the 'Schema' type at the very top! this is what parsing the schema-schema starts with!

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.

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!).
schema/gen/go/_demo/omg-schemas/schema/parse_test.go Outdated Show resolved Hide resolved
schema/gen/go/_demo/omg-schemas/schema/parse_test.go Outdated Show resolved Hide resolved
- 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 warpfork force-pushed the schema-schema-exercise branch from 812202f to 2b7b3f0 Compare September 10, 2020 11:58
Base automatically changed from union-tests-and-fixes to master September 10, 2020 12:01
@warpfork warpfork merged commit 1da0daf into master Sep 10, 2020
@warpfork warpfork deleted the schema-schema-exercise branch September 10, 2020 12:09
@aschmahmann aschmahmann mentioned this pull request Feb 18, 2021
73 tasks
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants