Questions tagged [delimited-continuations]

A delimited continuation is a "slice" of a continuation frame that has been reified into a function

A delimited continuation is a "slice" of a continuation frame that has been reified into a function. Unlike regular continuations, delimited continuations return a value, and thus may be reused and composed.

44 questions
86
votes
7 answers

What are Scala continuations and why use them?

I just finished Programming in Scala, and I've been looking into the changes between Scala 2.7 and 2.8. The one that seems to be the most important is the continuations plugin, but I don't understand what it's useful for or how it works. I've seen…
Dave
  • 7,589
  • 12
  • 36
  • 42
63
votes
1 answer

Use MonadRef to implement MonadCont

There is a well known issue that we cannot use forall types in the Cont return type. However it should be OK to have the following definition: class Monad m => MonadCont' m where callCC' :: ((a -> forall b. m b) -> m a) -> m a shift ::…
Earth Engine
  • 10,048
  • 5
  • 48
  • 78
36
votes
1 answer

What exactly is a "continuation prompt?"

I'm trying to decipher the documentation call-with-continuation-prompt Applies proc to the given args with the current continuation extended by a prompt. The prompt is tagged by prompt-tag, which must be a result from either…
34
votes
2 answers

Why are delimited continuation primitives named "shift" and "reset"?

I think I understand (in general) what shift and reset mean. However I do not understand why they are named so ? What do shift and reset as Delimited Continuation primitives have to do with "shift" and "reset" words in English?
Michael
  • 10,185
  • 12
  • 59
  • 110
19
votes
3 answers

Is anyone using delimited continuations to do web development in Haskell?

Is anyone using delimited continuations for Haskell development, specifically web development? I find the topic fascinating I need something more accessible than what I've been studying. Here are the resources I've found so far: Shift To Control…
Deech
  • 2,223
  • 15
  • 20
14
votes
1 answer

What are the specifics about the continuations upon which Raku(do) relies?

The topic of delimited continuations was barely discussed among programming language enthusiasts in the 1990s. It has recently been re-emerging as a major thing in programming language discussions. Aiui continuations aren't directly exposed in Raku,…
raiph
  • 31,607
  • 3
  • 62
  • 111
10
votes
1 answer

How to translate shift/reset into delimcc?

I'm studying Oleg's and Asai's delimited continuations "for dummies" paper(http://pllab.is.ocha.ac.jp/~asai/cw2011tutorial/main-e.pdf) but this paper uses the shift/reset formalism instead of the prompt stuff available in Oleg's delimcc. So I have a…
9
votes
1 answer

What are modern continuation operators all about?

Back in the day, I thought I understood call/cc. These days I'm seeing a lot more references to "delimited" continuation operators, which seem to come in pairs like shift/reset, prompt/control, and sometimes more exotic ones. But I haven't seen a…
9
votes
2 answers

Cont monad shift

While trying to build some intuition for the ContT monad transformer I (perhaps unsurprisingly) found myself confused. The issue lies with the shiftT operation which doesn't seem to do anything useful. First a simplistic example of how one might use…
Taren
  • 674
  • 5
  • 11
9
votes
1 answer

What's the relationship between the async/await pattern and continuations?

I'm wondering what's the relationship between the async/await pattern (as known from Scala, F#, C#, etc.) and continuations: Is the async/await pattern a limited subset of full-blown continuations? (If true, how are continuations more…
soc
  • 27,983
  • 20
  • 111
  • 215
9
votes
1 answer

Using Scala continuations with while loops

I realize this is counter to the usual sense of SO questions, but the following code works even though I think it should not work. Below is a small Scala program that uses continuations with a while loop. According to my understanding of…
jcrudy
  • 3,921
  • 1
  • 24
  • 31
8
votes
1 answer

Examples of the difference between `prompt/control` and `shift/reset`

I am not sure I understand the difference between the delimited continuation operator pairs prompt/control and reset/shift. I understand some basic examples of use, but in those examples their behavior is the same. I have found this example in "On…
johjs
  • 81
  • 3
7
votes
1 answer

How is Prolog `shift`/`reset` like other languages?

I found an example of shift-reset delimited continuations in Haskell here: resetT $ do alfa bravo x <- shiftT $ \esc -> do charlie lift $ esc 1 delta lift $ esc 2 return 0 zulu x This…
Lynn
  • 10,425
  • 43
  • 75
6
votes
2 answers

Scala delimited continuations error at runtime

Scala newbie here, I just downloaded Eclipse 3.6.2 and Scala IDE 2.0.0-beta4 (with Scala 2.9.0.final). I create a new Scala project to try delimited continuations: package delimCCTests import scala.util.continuations._ object Test extends App { …
Mauricio Scheffer
  • 98,863
  • 23
  • 192
  • 275
5
votes
1 answer

How does `get` work in the CPS version of the State monad?

I am trying to understand continuation in general following this tutorial. However, I am having difficulties to understand following example in section 2.10: # let get () = shift (fun k -> fun state -> k state state) ;; get : unit => ’a =…
Jason Hu
  • 6,239
  • 1
  • 20
  • 41
1
2 3