1. 24 Jan, 2021 3 commits
    • Eric Myhre's avatar
      schema: so much boilerplate for feeding information to the Compiler that I... · d74ecb3e
      Eric Myhre authored
      schema: so much boilerplate for feeding information to the Compiler that I wrote another supplementary code generator.
      
      (I'm getting very weary of golang.)
      
      This new bit of codegen makes the compiler.go file fairly readable
      again, though, so I'm satisfied with it.
      
      The Compiler API is now complete enough that I can start repairing
      other things to use it properly.  The schemadmt.Schema.Compile()
      function and all of its helpers compile again now.  So does *most*
      of the whole codegen system... with the notable exception of all
      the hardcoded typesystem spawning which used the old placeholder
      methods which have now been stricken.
      
      TypeSystem now maintains order.  This allowed me to remove some
      sort operations from the code generator.  This also means the next
      time any existing codegen is re-run, the output file will shift
      significantly.  However, it shouldn't do so again in the future.
      d74ecb3e
    • Eric Myhre's avatar
      schema/compiler: move into schema package. · de9e49b0
      Eric Myhre authored
      As with parent commit: this is a checkpoint.  CI will not be passing.
      de9e49b0
    • Eric Myhre's avatar
      schema: working to unify interfaces and dmt. Intermediate checkpoint commit. · f1859e77
      Eric Myhre authored
      This commit does not pass CI or even fully compile, and while I usually
      try to avoid those, A) I need a checkpoint!, and B) I think this one is
      interestingly illustrative, and I'll probably want to refer to this
      diff and the one that will follow it in the future as part of
      architecture design records (or even possibly experience reports about
      golang syntax).
      
      In this commit: we have three packages:
      
      - schema: full of interfaces (and only interfaces)
      - schema/compiler: creates values matching schema interfaces
      - schema/dmt: contains codegen'd types that parse schema documents.
      
      The dmt package feeds data to the compiler package, and the compiler
      package emits values matching the schema interface.
      This all works very nicely and avoids import cycles.
      
      (Avoiding import cycles has been nontrivial, here, unfortunately.
      The schema/schema2 package (which is still present in this commit,
      but will be removed shortly -- I've scraped most of it over into
      this new 'compiler' package already, just not a bunch of the validation
      rules stuff, yet) was a dream of making this all work by just having
      thin wrapper types around the dmt types.  This didn't fly...
      because codegen'd nodes comply with `schema.TypedNode`, and complying
      with `schema.TypedNode` means they have a function which references
      `schema.Type`... and that means we really must depend on that
      interface and the package it's in.  Ooof.)
      
      The big downer with this state, and why things are currently
      non-compiling at this checkpoint I've made here, is that we have to
      replicate a *lot* of methods into single-use interfaces in the schema
      package for this to work.  This belies the meaning of "interface".
      The reason we'd do this -- the reason to split 'compiler' into its own
      package -- is most because I wanted to keep all the constructor
      mechanisms for schema values out of the direct path of the user's eye,
      because most users shouldn't be using the compiler directly at all.
      
      But... I'm shifting to thinking this attempt to segregate the compiler
      details isn't worth it.  A whole separate package costs too much.
      Most concretely, it would make it impossible to make the `schema.Type`
      interface "closed" (e.g. by having an unexported method), and I think
      at that point we would be straying quite far from desired semantics.
      f1859e77
  2. 25 Jun, 2019 1 commit
    • Eric Myhre's avatar
      Refactor of type/schema code. · 122c5338
      Eric Myhre authored
      - `typed.Node` -> now lives in the `impl/typed` package, more like
      other nodes.
      
      - Most of the other essential parts of reasoning about types moved
      to `schema` package.  ("typed.Type" seemed like a nasty stutter.)
      
      - `typed.Universe` renamed to `schema.TypeSystem`.
      
      - Current `Validate` method moved to `schema` package, but see new
      comments about potential future homes of that code, and its
      aspirational relationship to `typed.Node`.
      
      Conspicuously *not* yet refactored or moved in this comment:
      
      - The `typed/declaration` package -- though it will shortly be scrapped
      and later reappear as `schema/ast`.  The dream is that it would be
      neatest of all if we could generate it by codegen; but we'll see.
      (This would seem to imply we'll have to make sufficient exported
      methods for creating the `schema.Type` values... while we also want
      to make those immutable.  We'll... see.)
      
      - The `typed/gen` package is also untouched in this commit, but
      should similarly move shortly.  The codegen really ought to be built
      against the `schema.Type` reified interfaces.
      
      Overall, this drops the sheer nesting depths of packages a fair bit,
      which seems likely to be a good smell.
      122c5338
  3. 15 Jan, 2019 2 commits
    • Eric Myhre's avatar
      Introduce typedeclaration package. (Think "AST".) · b066cf1b
      Eric Myhre authored
      All of these struct definitions are horrifying similar in construction
      to the same-named definitions in the typesystem package: simply ever
      instance of a Type pointer is instead a TypeName string.  Despite being
      unattractive, this is correct: since typesystem can have pointers and
      cycles, and typedeclaration can't, this is what we end up with.
      Signed-off-by: default avatarEric Myhre <hash@exultant.us>
      b066cf1b
    • Eric Myhre's avatar
      Reboot typed dir. Now with child packages. · c8e3e1d4
      Eric Myhre authored
      See previous commit for more discussion of the child packages to come,
      or the schema.md file in the docs dir, which describes similar.
      
      Several large todos in comments.
      
      Quite importantly: typed.Node is now an **interface**, not a concrete
      struct itself.  The godoc comment should explain this nicely; long
      story short, this is going to be relevant when we get to codegen and
      other advanced form of native integration.
      Signed-off-by: default avatarEric Myhre <hash@exultant.us>
      c8e3e1d4