semantic
semantic copied to clipboard
Generate datatypes of kind (* -> *) -> (* -> *) from Tree-Sitter syntax definitions
@dcreager suggested I add this issue, after a long in-person discussion about what work could be shared between Semantic and the Cubix framework ( http://cubix-framework.com ), as they use strikingly similar technology for different goals.
He told me about @aymannadeem's work using Template Haskell to generate datatypes of kind *
from Tree-Sitter definitions. Given that, it should be a small amount of work to additionally generate definitions of kind (* -> *) -> (* -> *)
.
Why are these significant? Semantic has hitherto been based on datatypes of kind (* -> *)
. These represent unsorted signature fragments: datatypes that can be modularly combined into different languages and dialects, but where each node is essentially untyped / dynamically-typed. Lifting these to sort (* -> *) -> (* -> *)
adds sort information to each node, making it possible to have datatypes-a-la-carte style definitions of programming languages with 0 information loss.
This is the approach of multi-sorted compositional data types ( https://www.researchgate.net/publication/228841104_Compositional_data_types ). The Cubix paper ( http://www.jameskoppel.com/files/papers/oopsla18main-p221-p.pdf ) describes a transformation from datatypes of kind *
to ones of kind (* -> *) -> (* -> *)
, which is implemented in the comptrans library ( http://hackage.haskell.org/package/comptrans ).
I've argued in my paper that any frameworks which (a) enables building multi-language tools, and (b) preserves enough information to do transformation, will need to be written in a similar way.