<div dir="ltr"><div>The resumption monad is even simpler, unfortunately I&#39;m not aware of any beginner level tutorials. <br><br></div>William Harrison at the University of Missouri has some papers introducing resumption monads but the presentations then move very quickly.<br>
<div><br><div><div class="gmail_extra"><br><br><div class="gmail_quote">On 12 March 2013 11:53, Ertugrul Söylemez <span dir="ltr">&lt;<a href="mailto:es@ertes.de" target="_blank">es@ertes.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">
<br>
</div>Not directly answering your question, but what you need is called<br>
coroutines, and there are better monads for that purpose.  This is how<br>
the Cont monads are defined:<br>
<br>
    newtype Cont r a = Cont ((a -&gt; r) -&gt; r)<br>
<br>
But what you really need here is called a Coroutine monad:<br>
<br>
    newtype Coroutine f a = Coroutine (Either (f (Coroutine f a)) a)<br>
<br>
Don&#39;t worry about that scary type, because if you look closely you will<br>
find that this is just Free as defined in the &#39;free&#39; package:<br>
<br>
    data Free f a<br>
        = Free (f (Free f a))<br>
        | Pure a<br>
<br></blockquote></div><br></div></div></div></div>