[Haskell-cafe] synchronous channels in STM

Tim Newsham newsham at lava.net
Thu Oct 9 13:02:03 EDT 2008

> I was wondering if it was possible to implement synchronous channels
> within STM. In particular, I'd like to have CSP-like send and recv primitives
> on a channel that each block until the other side arrives to complete
> the transaction.
> I think I've convinced myself that it's not possible, but
> anyone care to differ?

Not quite the same thing, but you can implement synchronous message
passing fairly easily with MVars.  Here's a small example that
builds coroutines, courtesy of ddarius:


you could modify this slightly to have the receiver release the
sender as soon as the message is received, if that's what you wanted.
Is this close enough for you, or does it have to be in STM?

>  cheers,
>    rog.

Tim Newsham

More information about the Haskell-Cafe mailing list