continuations Questions

1

Solved

The codensity monad on a type constructor f is defined by: newtype C f a = C { unC ∷ forall r. (a → f r) → f r } It is well known that C f is a monad for any type constructor f (not necessarily c...

1

Solved

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 T...

2

Solved

The following is a simple example of using delimited continuation (reset/shift): import Control.Monad import Control.Monad.Trans import Control.Monad.Trans.Cont test :: Integer test = evalCont . r...
Workman asked 1/7, 2022 at 18:48

1

Solved

Raku's state declarator can be used to give a subroutine or other block its own local state that persists across multiple invocations of the function: sub f { state $n++ } say f; # OUTPUT: «0» say ...
Jacelynjacenta asked 5/10, 2021 at 18:5

1

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, pro...

3

It’s common for explanations of continuations to say that a continuation represents the “rest of the program” (or similar phrasing). But there’s plainly a boundary at which the continuation stops c...
Lentigo asked 13/8, 2021 at 21:44

2

Solved

Here is some code deciding whether a list is a palindrome in n+1 comparisons, in "direct style" pal_d1 :: Eq a => [a] -> Bool pal_d1 l = let (r,_) = walk l l in r where walk l [] =...
Methaemoglobin asked 12/3, 2021 at 15:12

0

I'm trying to build a streaming library using the abstractions described in the paper "Faster coroutine pipelines". I've modified the code so that it correctly handles pipeline exiting (i...
Jillion asked 14/2, 2021 at 7:16

2

Solved

Compiling without Continuations describes a way to extend ANF System F with join points. GHC itself has join points in Core (an intermediate representation) rather than exposing join points directl...
Flyblow asked 2/8, 2020 at 14:44

1

Solved

As State monad can be factorized into Product (Left - Functor) and Reader (Right - Representable). Is there a way to factorize Continuation Monad? Below code is my attempt, which wont type check...
Hollah asked 17/4, 2020 at 9:5

3

I just made a curious observation regarding the Task.WhenAll method, when running on .NET Core 3.0. I passed a simple Task.Delay task as a single argument to Task.WhenAll, and I expected that the w...

10

Solved

I've tried several times to grasp the concept of continuations and call/cc. Every single attempt was a failure. Can somebody please explain me these concepts, ideally with more realistic examples t...
Sideling asked 4/3, 2009 at 22:30

5

Solved

I've been considering the new async stuff in C# 5, and one particular question came up. I understand that the await keyword is a neat compiler trick/syntactic sugar to implement continuation passi...
Gapin asked 5/10, 2011 at 14:40

7

Solved

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 understa...
Dermatosis asked 3/10, 2009 at 5:54

3

Solved

Here is a naive implementation of a right fold: const foldr = f => acc => ([x, ...xs]) => x === undefined ? acc : f(x) (foldkr(f) (acc) (xs)); This is non-tail recursion and hence w...

2

Please note that even though the example in this question is encoded in Javascript, the underlying concepts are common in Haskell and I while I prefer to express myself in Javascript I also appreci...

6

Solved

The Wikipedia article on Continuation says: "In any language which supports closures, it is possible to write programs in continuation passing style and manually implement call/cc." Either that is ...
Towns asked 13/5, 2010 at 14:33

5

Solved

I'm reading through Some Tricks for List Manipulation, and it contains the following: zipRev xs ys = foldr f id xs snd (ys,[]) where f x k c = k (\((y:ys),r) -> c (ys,(x,y):r)) What we ...
Cryptocrystalline asked 14/5, 2019 at 1:59

2

Solved

I am coming from a OOP, non-functional background, so I am having trouble fully visualizing several online examples regarding continuation passing. Also, functional languages like Scheme don't have...
Temporize asked 27/7, 2016 at 11:29

3

Solved

Here is my Task implementation (i.e. a sort of Promise but complying with the monad laws and cancelable). It works rock solid: const Task = k => ({runTask: (res, rej) => k(res, rej)});...

1

Solved

I study delimited continuations and am currently playing with discarding them to obtain an effect similar to raising exceptions. Here is what causes me trouble: const structure = type => c...

1

Solved

I am having trouble implementing exceptions (handle and raise) using a dynamically scoped variable and abort. This question came from reading the paper A syntactic theory of dynamic binding, sectio...
Reheat asked 22/10, 2018 at 23:8

3

Solved

There are some questions about what Scala continuations are (here and here). But the answers only try to explain it. So in this question I'm asking for a formal definition of what (Scala's) delimit...
Outflow asked 13/1, 2012 at 10:36

11

Is there a good implementation of continuations in Java? If so, what is the overhead like? The JVM wasn't designed with these sort of things in mind, right? So is this kind of going against the gr...
Rondel asked 21/9, 2009 at 18:36

1

Solved

Say I have a Task that generates an int, and a callback that accepts an int: Task<int> task = ...; Action<int> f = ...; Now I want to set it up so that once the task has completed ...
Phillisphilly asked 19/4, 2018 at 12:35

© 2022 - 2025 — McMap. All rights reserved.