Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit models which just use type dispatch #176

Open
kris-brown opened this issue Dec 9, 2024 · 0 comments · May be fixed by #177
Open

Explicit models which just use type dispatch #176

kris-brown opened this issue Dec 9, 2024 · 0 comments · May be fixed by #177
Assignees
Labels
enhancement New feature or request

Comments

@kris-brown
Copy link
Collaborator

kris-brown commented Dec 9, 2024

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) = f

So 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 of cat = CatC()?

No: maybe CatC implements some other theories (e.g. Th2Category) in different ways that will not be implemented by mere dispatch.

@kris-brown kris-brown self-assigned this Dec 9, 2024
@kris-brown kris-brown added the enhancement New feature or request label Dec 9, 2024
@kris-brown kris-brown linked a pull request Dec 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant