HyperSyn: Macro Syntax for Open Hypergraphs
This library provides a macro def_arrow for constructing
open hypergraphs.
The main idea is to use the host language (Rust) to write "metaprograms" which generate an OpenHypergraph.
In short, you can write something like this:
... which defines a function full_adder_arrow, which produces the following
open hypergraph when run:

A complete version of this example is in ./examples/adder.rs.
How It Works
You write a function like the following:
/// Build a term representing x^(2^n)
!
Your function can have two kinds of arguments:
- "Meta" arguments - having a normal rust type
- "Ground" arguments - with type
var!(value), wherevalueis a value of typeObject.
It should return one of:
- The unit type
() - A single
var!(..) - A tuple
(var!(t0), var!(t1), .., var!(tn))
The function body uses the
Var interface
of Open Hypergraphs
to construct an OpenHypergraph<Object, Operation>.
Specifically, the def_arrow(Object, Operation, exp_2n_arrow) annotation
defines a new function exp_2n_arrow with only the "meta" arguments of your
function.
In this example, the original function is first transformed to add a "state" parameter:
The generated exp_2n_arrow function is then generated:
Notice how the exp_2n_arrow has all the parameters of exp_2n except for those annotated with var!.