2 ms·
Algebraic effects are in delimited continuation territory, operating on the program stack. No amount of monad shenanigans is going to allow you to immediately j
by davery22 1y ago
Algebraic effects are in delimited continuation territory, operating on the program stack. No amount of monad shenanigans is going to allow you to immediately jump to an effect handler 5 levels up the call stack, update some local variables in that stack frame, and then jump back to execution at the same point 5 levels down.
- grg0 1y agoThat sounds like a fucking nightmare to debug. Like goto, but you don't even need to name a label.
- vkazanov 1y agoWell, you test the fact that the handler receives the right kind of data, and then how it processes it. And it is useful to be able to provide these handlers in tests. Effects are AMAZING
- cryptonector 1y ago> Like goto, but you don't even need to name a label. That's what exceptions are. But effects don't cause you to see huge stack traces in errors because the whole point is that you provide the effect and values expected and the code goes on running.
- AdieuToLogic 1y ago>> Like goto, but you don't even need to name a label. > That's what exceptions are. In many contexts I agree. However, the difference here is exceptions are one-way execution control transfers. Remember what was originally said: No amount of monad shenanigans is going to allow you to immediately jump to an effect handler 5 levels up the call stack, update some local variables in that stack frame, and then jump back to execution at the same point 5 levels down. Jumping "5 levels up the call stack", modifying some state, then jumping back "5 levels down" is to me pretty much the definition of a nightmare to reason about.
- agumonkey 1y agoclos condition system is said to be just that, people seem to like it also this kind of non local stack/tree rebinding is one way to implement prolog i believe
- tome 1y agoQuite the opposite, that's exactly what continuation monads do, for example `ContT`, and more structured versions such as `freer`. Those essentially simulate a stack rather than using the actual RTS stack. For the latter there are `eff` and `bluefin-algae` (the latter very much work in progress). So yes, in Haskell at least, monads are the right API for deli meted continuations. https://www.stackage.org/haddock/lts-23.15/transformers-0.6.1.0/Control-Monad-Trans-Cont.html#t:ContT https://www.stackage.org/haddock/lts-23.15/transformers-0.6.... https://hackage.haskell.org/package/freer-0.2.4.1 https://hackage.haskell.org/package/freer-0.2.4.1 https://github.com/lexi-lambda/eff https://github.com/lexi-lambda/eff https://hackage.haskell.org/package/bluefin-algae https://hackage.haskell.org/package/bluefin-algae