AlgebraicJulia / AlgebraicJulia/Catlab.jl
`@formula` macro like `@program`
- Dominant language
- Julia
- Stars
- 724
- Forks
- 73
- PR merge metrics
- No merged PRs in 30d
Description
I think we should have a macro for writing formulas within the scope of a presentation. When you do
```julia
@present P (FreeSMCwithDiagonals) begin
T::Ob
f::Hom(T,T)
end
@program P (x::T) begin
y = f(x)
return y,y
end
```
Catlab knows that `f` is referring to the generating morphism in `P` that is named `:f`. If you want to do a similar thing with the algebraic expression api, you would need to do
```julia
T, f = generators(P, [:T, :f])
compose(mcopy(T), f)
```
In that case the T,f escape into the julia namespace as julia variables.
It would be nice to do
```julia
@formula P begin
compose(mcopy(T), f)
end
```
and have Catlab recognize that the `T,f` variables should be the generators from `P`.
Contributor guide
Assessment
This issue has not been assessed yet.