Skip to content

Commit

Permalink
Simplify, upgrade, and type-stabilize dom_to_graph
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Arlin committed Feb 23, 2024
1 parent 2d19d42 commit 579d1b7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/categorical_algebra/FinCats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -559,15 +559,16 @@ end
"""
Reinterpret a functor on a finitely presented category
as a functor on the equivalent category (ignoring equations)
free on a graph.
free on a graph. Also normalizes the input to have vector ob_map
and hom_map, with valtype optionally specified. This is useful when
the domain is empty or when the maps might be tightly typed but need to
allow for types such as that of identity morphisms upon mutation.
"""
function dom_to_graph(F::FinDomFunctor{<:FinCatPresentation,<:Cat{Ob,Hom}}) where {Ob,Hom}
function dom_to_graph(F::FinDomFunctor{Dom,<:Cat{Ob,Hom}},obtype=Ob,homtype=Hom) where {Dom,Ob,Hom}
D = dom(F)
g , obs, homs = graph(D),Dict(pairs(ob_generators(D))), Dict(pairs(hom_generators(D)))
C = FinCat(g)
FinDomFunctorMap(Ob[ob_map(F,obs[i]) for i in 1:length(obs)],Hom[hom_map(F,homs[i]) for i in 1:length(homs)],C,codom(F))
C = FinCat(graph(D))
FinDomFunctorMap(obtype[ob_map(F,ob) for ob in ob_generators(D)],homtype[hom_map(F,hom) for hom in hom_generators(D)],C,codom(F))
end
dom_to_graph(F::FinDomFunctor) = F
function Base.show(io::IO, F::T) where T <: FinDomFunctorMap
Categories.show_type_constructor(io, T); print(io, "(")
show(io, F.ob_map)
Expand Down

0 comments on commit 579d1b7

Please sign in to comment.