diff --git a/src/stdlib/models/FinSets.jl b/src/stdlib/models/FinSets.jl index 7864dbe8..8bf8d303 100644 --- a/src/stdlib/models/FinSets.jl +++ b/src/stdlib/models/FinSets.jl @@ -27,7 +27,7 @@ end compose(f::Vector{Int}, g::Vector{Int}) = g[f] dom(f::Vector{Int}) = length(f) - codom(::Vector{Int}; context) = context[:c] + codom(::Vector{Int}; context) = context[:codom] end end diff --git a/src/stdlib/models/Op.jl b/src/stdlib/models/Op.jl index 9c34013f..cbb6da38 100644 --- a/src/stdlib/models/Op.jl +++ b/src/stdlib/models/Op.jl @@ -21,14 +21,16 @@ rename(nt::NamedTuple, d::Dict{Symbol,Symbol}) = NamedTuple(get(d, k, k) => v for (k, v) in pairs(nt)) -@instance ThCategory{ObT, HomT} (;model::OpC{ObT, HomT, C}) where {ObT, HomT, C} begin - Ob(x::ObT) = Ob(x; model=model.cat) - Hom(x::HomT, d::ObT, cd::ObT) = Hom(x, cd, d; model=model.cat) - id(x::ObT) = id(x; model=model.cat) - dom(f::HomT; context) = codom(f; model=model.cat, context) - codom(f::HomT; context) = dom(f; model=model.cat, context) +@instance ThCategory{ObT, HomT} [model::OpC{ObT, HomT, C}] where {ObT, HomT, C} begin + Ob(x::ObT) = Ob[model.cat](x) + Hom(x::HomT, d::ObT, cd::ObT) = Hom[model.cat](x, cd, d) + id(x::ObT) = id[model.cat](x) + dom(f::HomT; context) = + codom[model.cat](f; context=rename(context, Dict(:dom=>:codom, :codom=>:dom))) + codom(f::HomT; context) = + dom[model.cat](f; context=rename(context, Dict(:dom=>:codom, :codom=>:dom))) compose(f::HomT, g::HomT; context=nothing) = - compose(g, f; model=model.cat, + compose[model.cat](g, f; context=rename(context, Dict(:a=>:c, :c=>:a, :b=>:b))) end diff --git a/test/stdlib/models/Op.jl b/test/stdlib/models/Op.jl index c2a4b215..06295f1f 100644 --- a/test/stdlib/models/Op.jl +++ b/test/stdlib/models/Op.jl @@ -15,7 +15,7 @@ using .ThCategory @test compose([1,1,1,3,2], [5]) == [2] @test compose([1,1,1,3,2], [5]; context=(;)) == [2] @test codom([5]) == 1 - @test dom([5]; context=(c=10,)) == 10 + @test dom([5]; context=(dom=10,)) == 10 end end # module