AlgebraicJulia / AlgebraicJulia/Catlab.jl
@instance creates empty struct for model of category
- 主要語言
- Julia
- 星號
- 724
- 分支
- 73
- PR 合併指標
- 30 天內沒有已合併 PR
描述
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 ...
```
貢獻指南
評估
這個 Issue 還沒有評估資料。