AlgebraicJulia / GATlab.jl

GATlab: a computer algebra system based on generalized algebraic theories (GATs)
https://algebraicjulia.github.io/GATlab.jl/
MIT License
23 stars 2 forks source link

Models should declare which variables they actually need #71

Closed olynch closed 11 months ago

olynch commented 1 year ago

When a model implements a term constructor, it in theory has access to all of the variables in the context of that term constructor. However, oftentimes it does not need all of those variables. There should be some way of recording the variables that it actually needs, because this could be used to make a declared program faster.

For instance, a model of a preorder doesn't need to look at any of the variables when calling compose or id. So any programs in the theory of preorders can be compiled to no-ops.

This might be a premature optimization, because Julia might optimize things away in any case, so this is not high priority. But at some point, it might be worth doing.