rpc expanded a bit, not working yet
rpc: rewrite with ast/monoid and state monad separation (wip)