There doesn't seem to be anything preventing us from letting generators be higher-order (i.e. writing a generator that returns another generator). We can tag the creation point, and each call site of the created generator. tag directives will always apply to the trace that is the implicit argument to the most immediate enclosing @program.
Example:
@program higher_order_generator() begin
mu = tag(normal(0, 10), "mu")
std = tag(gamma(1, 1), "std")
# returns a generator that is a closure
@program () begin
# returns a draw from a normal
tag(normal(mu, std), "output")
end
end
There doesn't seem to be anything preventing us from letting generators be higher-order (i.e. writing a generator that returns another generator). We can tag the creation point, and each call site of the created generator.
tag
directives will always apply to the trace that is the implicit argument to the most immediate enclosing@program
.Example: