Thanks, Claude! I'm working on moving your example into the Vivid context.
Tom, indeed, that would be simpler! I wanted to use `toI`. But I don't see how to do that without hard-coding every choice of which parameter to send a message to.
For instance, suppose you've got a list of parameter names `["freq","amp" ..]` from which you want the code to choose a parameter `p` randomly every cycle, and set it to the value `x`. You can't write `set s (x :: I p)`, because the `p` in `I p` is a type-level variable rather than an ordinary one.
I considered keeping a list of functions `[setFreq, setAmp ..]` instead of a list of parameter names, but I haven't found how to represent such a list:
> :set -XDataKinds
> :set -XRankNTypes
> s <- synth boop ()
> [set s (3::I "amp"), set s (5::I "freq")]
• Could not deduce: Elem "freq" ' arising from a use of ‘set’
from the context: VividAction m
bound by the inferred type of it :: VividAction m => [m ()]
• In the expression: set s (5 :: I "freq")
In the expression: [set s (3 :: I "amp"), set s (5 :: I "freq")]
In an equation for ‘it’:
it = [set s (3 :: I "amp"), set s (5 :: I "freq")]