I think this is a really good idea from what I understand
I've toyed with js generators to attempt a limited version of this idea a few years ago
https://github.com/marcellerusu/capable-js and was surprised by the power of expressing certain things this way.