thema
thema copied to clipboard
Replace `kernel` package with `vmux`; introduce generics
This introduces generics in the base thema package, allowing the pairing of a Go type with a Schema
(TypedSchema
) and its corresponding Instance
(TypedInstance
).
Building on these generics, we replace the previous kernel
approach with a new vmux
(version multiplexer) package. This package has the same basic goal as the original kernels, but is less work and more elegantly shaped in its final product.
Rather than having two methods (Converge
, ConvergeJSON
) the user calls to pass bytes through a pipeline, vmux
contains four muxers, each of which are themselves callable functions following the same basic muxing pattern (accept all versions->see one), mapping from bytes to...
-
Untyped
:[]byte -> *thema.Instance
-
Byte
:[]byte -> []byte
-
Typed
:[]byte -> *thema.TypedInstance[T]
-
Value
:[]byte -> T
The pattern is also extensible for "middleware" in the future. The known case there is stepwise interception of Translate
on the basis of lacuna that may have been emitted in each translation step.
Also started using some of the go1.19 godoc hotlinking conventions.
- [ ] Move tests over from
kernel
- [ ] Remove
kernel
package - [ ] Clean up docs on helper funcs for generic binding
- [ ] Rewrite relevant tutorials
Fixes #53 Fixes #57