AlgebraicJulia / AlgebraicJulia/Catlab.jl

`@formula` macro like `@program`

Open
#150 0 comments 0 reactions 0 assignees View on GitHub
enhancement
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.