-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Interoperability between the old style of GATlab and the new one has been limited to creating models. One can create an old-style one (where implementation is just dictated by dispatch) by not providing a [model::MyModel] in the @instance declaration.
However, if one is consuming models, such as a function f(some_ThCategory_model, some_ThMonoid_model) then this can really only ever use the new GATlab models, since there's no reified thing to plug in which says "just use type dispatch".
However, GATlab could define a struct Dispatch end along with
Base.getindex(f, ::Dispatch) = fSo that compose[myDispatchModel](f::GATExpr, g::GATExpr) would just evaluate to whatever type dispatch says compose(f::GATExpr, g::GATExpr) should do. This is relevant to Catlab, where we want to use infrastructure which expects explicit models on the result of @symbolic_model, which currently just produces an old-style instance.
For a related and slightly different problem: consider that one might have a model (e.g. struct CatC which implements ThCategory with Category and Functor), and it's already the case that ThCategory.dom(::Functor), ThCategory.id(::Category), etc. are all defined. Here it would be convenient to have a macro which says "CatC should just use dispatch to implement ThCategory" rather than writing out a bunch of boilerplate. It could look like this:
@default_model ThCategory{Category, Functor} [model::CatC]Couldn't you just use
cat = Dispatch(ThCategory, [Category, Functor])instead ofcat = CatC()?
No: maybe CatC implements some other theories (e.g. Th2Category) in different ways that will not be implemented by mere dispatch.