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
2
votes
1 answer

early exiting a recursive procedure

Watching this video (11:56) It shows a recursive procedure that multiplies the numbers contained in a list The idea is that if the list contains a zero, the whole stack of recursive calls can be discarded and 0 can be returned So to save some…
user1632812
  • 431
  • 3
  • 16
2
votes
1 answer

How handler control stackframes are placed relative to each other in Koka?

I have a following Koka snippet here and I would like for someone to explain what happens to stackframes when handlers are invoked. I've tried to make handlers stack frames also visible by printing values & global counters and I have desugared when…
artemonster
  • 744
  • 4
  • 27
2
votes
1 answer

Nested delimited continuations transformations

I'm trying to understand delimited continuations, and I was reading this article: http://community.schemewiki.org/?composable-continuations-tutorial And I found this reset/shift transformation (reset (...A... (shift V E) ...B...)) ; --> (let…
2
votes
2 answers

Is there a programming language that natively supports delimited continuations?

I would like to know a programming languages that natively support delimited continuations. I do know that Scala used to have shift and reset, but those were removed; and I also know that Seaside seems to have something similar, but Seaside is a…
josh
  • 997
  • 1
  • 8
  • 13
2
votes
0 answers

Binary Tree sum with Scala Delimited Continuations

I am playing around with Scala and I am starting from some simple examples such as implementing binary trees. Having prior knowledge of functional programming (OCaml, F#) I was trying to replicate the common approach of using continuations in order…
2
votes
1 answer

Inconsistent behavior in Scala CPS framework

I'm trying to build a coroutine framework to enable batch data fetching by stepping through each data-dependent function in parallel. Here is what I have so far: http://pastie.org/7147798 This doesn't work def get(id: Long) = reset { // Is it not…
1
vote
1 answer

early exit with shift and reset

Trying to understand delimited continuations with Guile scheme I managed to grasp the vanilla conts (call/cc) thanks to this video (it's great) Now I'd like to move to delimited conts I have this minimal example of early exit made with…
user1632812
  • 431
  • 3
  • 16
1
vote
1 answer

Implementing the delimited continuation monad in JavaScript - `reset` idempotence bug

This is a tough one. I've been trying to code up various monads and this was the only one I couldn't find a succinct example anywhere, so I tried writing my own shift and reset using this test suite (JS) and this question (Agda) as reference. In…
1
vote
1 answer

How to express delimited continuations with pure functions only?

I worked through Oleg's tutorial of delimited continuations: newtype Cont r a = Cont{runCont :: (a -> r) -> r} instance Monad (Cont r) where return x = Cont (\k -> k x) Cont m >>= f = Cont (\k -> m (\v -> runCont (f v) k)) runC :: Cont r r ->…
user10675354
1
vote
1 answer

Is it possible to check if the current continuation is terminating?

Is it possible to define a procedure f such that it prints Exiting... if it is the last thing to do before exiting, and prints Not done yet... otherwise? For examples, (display "hello, world\n") (f) should give hello,…
1
vote
1 answer

Fibers / Coroutines vs Delimited Continuations

So I read a paper about concurrent work stealing deques here: http://open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3872.pdf. They mention "Child-Stealing vs Continuation Stealing" and they say that child stealing can require unbounded stack space to…
Jesse Lactin
  • 301
  • 3
  • 12
1
vote
0 answers

Pause computation with continuation

I'm trying to pause a computation and later resume it on demand (upon a prompt from the user). It should resemble something like the following, only using the continuation monad. import Control.Monad.IO.Class (liftIO,MonadIO(..)) import Data.Void f…
1
vote
1 answer

Pipelines in Python? - Think async.js / Haskell's `do` / F#'s `|>`

How can Continuation-passing style be facilitated from Python? (I think that's the right term) My code is starting to get messy, I have map, filter and chains of lambdas like so: (lambda a,b: (lambda c:(lambda d: d*d)(c-b))(a*b))(5,6) "Pipeline…
A T
  • 13,008
  • 21
  • 97
  • 158
1
vote
3 answers

What type parameters should I use to make List.map work with delimited continuations?

I'm basically following the example given at the Scala API page for delimited continuations. The code below works fine: import scala.util.continuations._ import scala.collection.mutable.HashMap val sessions = new HashMap[Int, Int=>Unit] def…
Mike Stay
  • 1,071
  • 8
  • 17
1 2
3