3 ms·
That kind of feels like cheating though. I mean, the complicated part of a continuation is that it restores the same context and state that the app had right be
by penpapersw 9y ago
That kind of feels like cheating though. I mean, the complicated part of a continuation is that it restores the same context and state that the app had right before the plunge. But Haskell inherently doesn't have "floating" state, it's all self-contained within each parameter. So in Haskell it's more or less a fancy goto-statement.
- mbrock 9y agoThe linked module defines a "monad transformer" that can wrap other monads with a continuation-capturing layer. This means, among other things (Haskell's solution is awesomely general) that you can indeed use it with state, if you compose it with the state monad, or even the IO monad. (The bottom of the documentation page has a contrived example of this.)