sempre-plot
sempre-plot copied to clipboard
improve the action space
(: init ...)
formulas should modify the current context
Proposal
Value can be used to construct other Value, or be set by itself
- for example, a channel cannot be constructed without a type
- so we should be able to put InitChannelDef into $.encoding
- How can we use some of the checks in init for set actions?
Ideally, the interface should provide a clean way for us to add new actions deemed necessary perhaps we need $Path $Action, where action is performed on the path, and comes with its own checks?
Currently
- $Action <- $Path $Value
- $Value is constructed from grounded arguments
- and possibly some floating arguments when needed
- we can already new SemanticFn for new types of values, which can be checked via schema validation
- but unclear how value-specific checks should work (maybe in JoinFn, but not ideal).
Do you think you can merge some of the parts used in init into set formulas and design a good interface for doing more customized checks, in addition to just schema validation?
@sidaw Could you give some examples of path actions ($Action) and the "value-specific checks"?
Also, shouldn't the check be path-specific instead of value-specific? What do you mean by value-specific?
Here's one proposal for generic value setting and constraint checking:
- value = primitiveValue | compositeValue
- primitiveValue is either grounded or floated
- For floated primitiveValue, we can use a special token "ANY" that expands into a random compatible value when needed
- compositeValue = template + value + value + ...
- template is like FIELDDEF = {"field": ___, "type": ___}
- Define one template for each BNF category
- Put template-specific checks here!
- action = path + value
- e.g., path = "$.encoding.color"; value = {"field": "year", "type": "quantitative"}
- Put path-specific checks here!
- ROOT = action
@ppasupat Sounds good. We do not need to handle many of the categories, but we should handle important ones (from looking at vega-lite examples, encoding.blah seems the most important by far, until we start to consider compositions of whole specs) and make it conceptually clean to add more.