4 ms·
The example for the Yield effect [1] looks suspiciously like the condition system of Common Lisp and restarts. [1] https://effekt-lang.org/#intro-handlers http
by i_don_t_know 5y ago
The example for the Yield effect [1] looks suspiciously like the condition system of Common Lisp and restarts.
[1] https://effekt-lang.org/#intro-handlers https://effekt-lang.org/#intro-handlers
- mananaysiempre 5y agoAndrej Bauer’s Eff[1] circa 2012 explored the connections with exception systems and delimited continuations pretty thoroughly, IIRC, though I’m not yet sure how the present language relates to it. [1] https://www.eff-lang.org/ https://www.eff-lang.org/
- hencq 5y agoYou can implement some version of that as long as you have dynamic scope. For simplicity let's just use pseudocode with globals: # By default Yield throws an exception global Yield = function(n) {throw n}; def example() = { var produce = true; var n = 0; while (produce) { produce = Yield(n) n = n + 1 } println("done") } # Temporarily set the global Yield to be a different function with(Yield = function(n) { println(n); return n < 3;}) { example(); } Where algebraic effects typically differ is that the handler receives a continuation. Potentially you could do more with that than just resume. You could for example store that continuation and build coroutines that way. That makes them essentially the same as delimited continuations. That's something that Common Lisp does not support. I'm not sure how that works in Effekt though. Since there seems to be a 'resume' keyword they might not be as powerful as delimited continuations.
- agumonkey 5y agoThis has been mentionned twice (including you) in this month. Makes me very curious about both CL restarts (never used them for real) and AEff
- Jtsummers 5y agohttps://link.springer.com/book/10.1007/978-1-4842-6134-7 https://link.springer.com/book/10.1007/978-1-4842-6134-7 That's a pretty good book (admittedly I have not finished it yet, life got in the way) about CL's condition system. Worth a read if it's something that interests you. Also, I'm pretty sure that price dropped a lot from when I last looked. $10 for the print book isn't a bad price, and $7 for the ebook.
- agumonkey 5y agoI might actually buy one of these. Thanks.