Comment by ufo
7 years ago
Coroutines are a mechanism that you can use to implement algebraic effects. When the coroutine yields, it yields the tagged effect object which can be used to determine what effect handler to run, and after that whether to resume the evaluation of the coroutine or not.
One obvious difference is that in a statically-typed language with algebraic effects the compiler checks that all the effects are being handled correctly. If you implement these in raw Lua a stray "coroutine.yield" can ruin everything if it doesn't return a properly formed tagged event object.
No comments yet
Contribute on Hacker News ↗