AlgebraicJulia / AlgebraicPetri.jl

Build Petri net models compositionally

Home Page:https://algebraicjulia.github.io/AlgebraicPetri.jl/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Type piracy in visualization functions

epatters opened this issue · comments

The visualization module has lots of type piracies. For example, the Graph constructor is defined for Multispan, Subobject, and ACSetTransformation, but AlgebraicPetri doesn't own any of these types, nor are the methods defined here general enough for those types.

commented

All of those types have type parameters for the underlying category right? So we could use the type parameters to narrow them to Multispans of ACSetTransformations of Reaction Nets, right? Would that be sufficient to avoid Type Piracy?

Right, the three cases I mentioned can be fixed by specializing the types in the methods.

There's also stuff like this:

==(a::NodeID, b::NodeID) = isequal(a.name, b.name) && isequal(a.port, b.port) && isequal(a.anchor, b.anchor) && true
hash(a::NodeID, h::UInt) = hash(a.anchor, hash(a.port, hash(a.name, hash(:NodeID, h))))
==(a::Edge, b::Edge) = isequal(a.path, b.path) && isequal(a.attrs, b.attrs) && true
hash(a::Edge, h::UInt) = hash(a.path, hash(a.attrs, hash(:Edge, h)))

If it's helpful to have equality and hash methods for these types, they should be upstreamed to Catlab.

Great, thanks for catching this! I'll work on getting those types correctly parameterized once we get #69 merged.

It would be helpful to have equality and hash methods for NodeID and Edge, so I'll get an Issue posted and PR made for that.

I think this has been resolved in the latest version of AlgebraicPetri. Let me know if I'm mistaken and I can reopen this!