Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define alias methods in @instance rather than @theory #190

Open
wants to merge 1 commit into
base: runtime_typechecking
Choose a base branch
from

Conversation

kris-brown
Copy link
Collaborator

@kris-brown kris-brown commented Jan 21, 2025

This undoes a change made earlier in this series of PRs where the code which generated alias was methods was changed. The change was to allow us to define just once

ThCategory2.*(anymodel::WithModel, xs...) = ThCategory2.composeH(anymodel, xs...)

whenever, e.g., ThCategory2 is defined, rather than handling aliases for every single theory + model combination in the @instance code.

The issue only revealed itself towards the end of the Catlab refactor, when it became clear two different theories (ThCategory2 and ThCopresheaf) both import the same symbol, Base.:* and made them aliases for differently named things (composeH and act, respectively). This means when the second theory is defined, we emit the code

ThCopresheaf.*(anymodel::WithModel, xs...) = ThCopresheaf.act(anymodel, xs...)

which actually overwrites the association of Base.:* with ThCategory2.composeH (it's alarming the Julia precompiler did not print a warning of method overwriting!).

So the alias methods are now generated only whenever the corresponding other method is generated (this is still capable of causing type conflicts, but these are much less likely because one must be using the same model with the same types).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant