Hacker News new | ask | show | jobs
by nikita2206 397 days ago
Have you thought of using generators as a closest example to compare effects to? I think they are much closer to effects than exceptions are. Great explainer anyway, it was tge first time I have read about this idea and it was immediately obvious
2 comments

Full blown algebraic effects are multi-shot, meaning you can resume from the same raised effect multiple times. Generators can only resume from a point in the execution a single time.

But yes, you can implement single-shot effects with generators.

Exceptions are usually used because the syntax for "performing" exceptions (throw) vs handling exceptions (try-catch) is familiar to most programmers, and is basically the same as the syntax for "performing" an effect vs handling the effect, except that the latter also includes resuming a function.

It would be cool to see how generators will be implemented with algebraic effects.