4 ms·
They are related. You can specify effects with monads (http://goto.ucsd.edu/~nvazou/koka/icfp15.pdf http://goto.ucsd.edu/~nvazou/koka/icfp15.pdf for example), a
by anchpop 5y ago
They are related. You can specify effects with monads (http://goto.ucsd.edu/~nvazou/koka/icfp15.pdf http://goto.ucsd.edu/~nvazou/koka/icfp15.pdf for example), and continuations can be expressed with monads (and therefore as an effect). I believe monads and effects are more general than continuations though. I’m not an expert so don’t quote me haha
- compressedgas 5y agoI think that they are each expressible with the other. Monadic reflection can be implemented with continuations. Effects, specifically effect handlers, can be implemented with delimited continuations which weren't mentioned in this article. Delimited continuations and undelimited continuations can implement each other. Both undelimited continuations and delimited continuations can be implemented as a monad. The main issue with all of this and why effects exist and why monads and delimited continuations aren't enough has to do with the fact that delimited continuations can't be easily type checked and monads aren't open for extension. I did not like that undelimited continuations were not mentioned. They are so much easier to understand than call/cc continuations as they are the rectification of some segment of the return stack as a function which when called returns through that segment and then to the caller like a regular function.
- ashton314 5y agoCan you recommend some papers on this?
- manu3000 5y agoOleg has written a lot about this: http://okmij.org/ftp/continuations/ http://okmij.org/ftp/continuations/ you can also google "oliver danvy delimited continuations" or "felleisen delimited continuations"
- hencq 5y ago> I did not like that undelimited continuations were not mentioned. call/cc continuations are undelimited continuations right? It sounds like you're talking about call/ec, escape continuations or one-shot continuations. They're essentially longjmp in C.
- compressedgas 5y agoI meant delimited. However copy and paste had other plans. All of call/cc, call/ec, call/1cc are effectively jumps to a saved stack. (The difference between these is that the first can be used more than once and both to enter and exit. The second can only be used to exit. The third can only be used once.) shift is instead captures the return stack up to the first reset and forms a function out of it that when called runs the rest of each of the frames before returning to the caller of that created function.
- a1369209993 5y ago> I did not like that undelimited continuations were not mentioned. They are so much easier to understand than call/cc continuations as they are the rectification of some segment of the return stack as a function which when called returns through that segment and then to the caller like a regular function. I think you mean delimited continuations? "Undelimited continuations" is call/cc.
- compressedgas 5y agoI edited that sentence when I forgot the 'not' but I missed removing the 'un'. Yes, shift and reset, delimited continuations were not mentioned.