AlgebraicJulia / Catlab.jl

A framework for applied category theory in the Julia language
https://www.algebraicjulia.org
MIT License
608 stars 58 forks source link

Simplify, upgrade, and type-stabilize dom_to_graph #891

Closed KevinDCarlson closed 7 months ago

KevinDCarlson commented 7 months ago

DataMigrations.jl uses the dom_to_graph function to convert a category from a presentation to a graph so that it can be fed into the Limits functionality. At the same time it has to do some typecasting to handle the fact that its diagrams might containing at least three concrete types--SetFunctionCallable,SetFunctionId,FinDomFunctionInt--while also allowing for mutations during the process of populating partially defined diagram and then constructing bipartite graphs for the limit.

This PR modifies dom_to_graph to ensure that the output will always have dom a FinCatGraph, ob_map a vector of obtype, and hom_map a vector of homtype. There seems to be no reason as yet to allow codom(F) to be modified, although maybe there will be such a need someday.

Requesting a patch release. In some sense this is a breaking change since the old function wouldn't change a functor with domain other than a FinCatPresentation, but I don't have any reason to believe this function's ever been called outside of the DataMigrations.jl context. And the breaking could only occur if somebody was relying excessively on implementation details of the input functor such as the ob_map being a Dict anyway--this function doesn't change the functor's semantics.