[Haskell-beginners] Suspend/resume computation using Cont monad and callCC
stephen.tetley at gmail.com
Tue Mar 12 18:54:16 CET 2013
The resumption monad is even simpler, unfortunately I'm not aware of any
beginner level tutorials.
William Harrison at the University of Missouri has some papers introducing
resumption monads but the presentations then move very quickly.
On 12 March 2013 11:53, Ertugrul Söylemez <es at ertes.de> wrote:
> Not directly answering your question, but what you need is called
> coroutines, and there are better monads for that purpose. This is how
> the Cont monads are defined:
> newtype Cont r a = Cont ((a -> r) -> r)
> But what you really need here is called a Coroutine monad:
> newtype Coroutine f a = Coroutine (Either (f (Coroutine f a)) a)
> Don't worry about that scary type, because if you look closely you will
> find that this is just Free as defined in the 'free' package:
> data Free f a
> = Free (f (Free f a))
> | Pure a
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners