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

@instance creates empty struct for model of category #950

Open
quffaro opened this issue Nov 6, 2024 · 0 comments
Open

@instance creates empty struct for model of category #950

quffaro opened this issue Nov 6, 2024 · 0 comments

Comments

@quffaro
Copy link
Member

quffaro commented Nov 6, 2024

In TemporalData, I was led to the following design pattern: I instantiate a category like so, but I also create an empty struct StrictIntervalCat so I can explicitly reference the model of the category theory in code.

""" The category of intervals and their strict embeddings (inclusions). """
abstract type StrictIntervalCat{T} <: Category{Interval, StrictIntervalEmbedding, SmallCatSize} where T end

""" The instantiation of the category of strict embeddings """
@instance ThCategory{Interval, StrictIntervalEmbedding} begin
  dom(f::StrictIntervalEmbedding) = f.dom
  codom(f::StrictIntervalEmbedding) = f.codom
  id(i::Interval) = StrictIntervalEmbedding(i)
  function compose(f::StrictIntervalEmbedding, g::StrictIntervalEmbedding)
    StrictIntervalEmbedding(dom(f), codom(g))
  end
end

I know @kris-brown is working on a deeper integration of GATlab with Catlab, but I think we should be able to refer to the model of the category explicitly after we instantiate it. Perhaps @instance can produce a struct so we can dispatch on it?

Naively,

StrictIntervalCat = @instance ThCategory{Interval, StrictIntervalEmbedding} begin ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant