AlgebraicJulia / AlgebraicJulia/GATlab.jl
Explicit models which just use type dispatch
- Langage dominant
- Julia
- Étoiles
- 43
- Forks
- 4
- Métriques de merge des PR
- Aucune PR mergée en 30 j
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
```julia
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:
```julia
@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.
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Évaluation
Cette issue n'a pas encore été évaluée.