Unidef stands for define once, use everywhere. It aims for define data structures in a unified format. It combines parsers, transformers, and emitters. By supporting multiple parsers, it can use multiple data sources. By supporting multiple emitters, the data structure can be converted into many endpoint languages.
Unidef is similar to JSON Type Definition. When I was writing this program, I'm not aware of the JSON Type Definition. Unidef has some advantages over JSON Type Definition:
- Unidef supports more complex and customized inferring
- Unidef gives finer control over types
- Unidef can do transpiling and code generation
- Unidef supports more input types
# scala version
sbt publishLocal
sbt nativeImageRunAgent
sbt nativeImage
# python version
pip install -e .
- Unidef fields/variants
- JSON message example
- FIX message example
- JSON Schema
- OpenAPI Schema object
- JavaScript
- protobuf
- JSON Type Definition
- Python peewee
- Python pydantic
- Rust serde struct
- Rust serde_json/ijson
- SQL definition
- JSON Schema
- OpenAPI Schema
- JavaScript
- Replace Pydantic with typedmodel
- Replace RustLineNode, RustBulkNode, etc with jinja2 template engine for advanced indentation control
- Build a common set of AST nodes
Right now inner model is now mixed key-value with validations. The next step should be conversion from and to well-defined python object
I decided to rewrite it with scala 3. Because
- Python is too slow
- Python is not expressive with pattern matching
- Has GC, and no need to care about machine level details compared with Rust
Some reasoning:
TyNode is an independent concept that cannot exist on its own AstNode is a standalone concept, the minimal element to represent everything
I try to implement the tasty version to
- support parsing scala 3
- implement a interpreter in the same time
- try to do some optimization work(similar to LMS, but without intruding the original language)
- leave space for a transpile framework
- Add more tests for json schema
- Support anonymous struct with fields in yaml
- Support anonymous enum in yaml
- Use automatically generated TyNode and AstNode(self bootstrap)
- Use circe.json.HCursor to spot json parsing problem
- Support save actions: formatter, etc
- Simple SVN for code generated files
- Support most of what python version can do: Rust structs, FIX, sql ddl, python peewee/pydantic model, etc
- Replace Type and Ast with TyStruct