<p dir="ltr">That looks like a continuation monad to me. `C m a` can also be expressed as `Cont (Action m) a`, where Cont is from the transformers library.</p>
<p dir="ltr">In this case, I suggest looking at how the C type is used, rather than focusing on the Monad instance. Since it's all bog standard continuation passing so far, most likely the interesting part is elsewhere.</p>

<p dir="ltr">I'm on my phone so I can't supply links, but I hope this helps a bit.</p>
<div class="gmail_quote">On Jul 27, 2014 10:48 PM, "martin" <<a href="mailto:martin.drautzburg@web.de">martin.drautzburg@web.de</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello all,<br>
<br>
I am trying to understand the ideas of Koen Klaessen, published in Functional Pearls: "A poor man's concurrency" (1993).<br>
<br>
The code in the paper doesn't compile. E.g. uses "lambda dot" instead of "labmda arrow", i.e. the way the labmda<br>
calculus guys write things. Was that ever legal haskell or is this the result of some lhs2lex pretty printer?<br>
<br>
Anyways, I believe I was able to convert that into modern haskell syntax - at least it compiles. But I have trouble to<br>
understand the Monad instance presented there. Could anyobody walk me through the bind function?<br>
<br>
But even more important: how do you guys develop an intuition about what the bind operator does in a specific monad. I<br>
saw a Google tech talk where Douglas Crockford explains mondads in terms of Objects in javascript<br>
(<a href="https://www.youtube.com/watch?v=b0EF0VTs9Dc" target="_blank">https://www.youtube.com/watch?v=b0EF0VTs9Dc</a>), which was certainly enlightening, but I couldn't apply it to this<br>
particular modad.<br>
<br>
I also tried using something like Data Flow Diagrams. This kinda works for simple Mondads such as the state mondad, but<br>
I couldn't apply it to the concurrency mondad. In general DFDs are not very good when it comes to higher order functions.<br>
<br>
In any case here is the code. I made it more verbose than necessary in order to understand it (bind was originally just<br>
one line), but to no avail.<br>
<br>
<br>
newtype C m a = C ((a -> Action m) -> Action m)<br>
<br>
instance Monad m => Monad (C m) where<br>
        (C m) >>= k = C cont<br>
                where<br>
                    cont c = m (\a -><br>
                                        let C h = k a<br>
                                        in h c)<br>
        return x = C $ \c -> c x<br>
<br>
<br>
data Action m =<br>
        Atom (m (Action m))<br>
        | Fork (Action m) (Action m)<br>
        | Stop<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div>