
Hi,
On Sat, Mar 3, 2012 at 10:38 AM, Gregory Collins
Hi,
The tutorial I gave for CUFP 2011 was a multi-user web chat program using the Snap Framework. STM channels make this kind of problem super-easy to deal with. Don't be afraid of forking lots of Haskell threads for programs like this, because they're "green" threads, not OS threads (i.e. Haskell threads are M:N multiplexed onto OS threads) and as such they have very little overhead.
Maybe you'll find the code interesting: https://github.com/snapframework/cufp2011. The "business logic" of using STM channels is here: https://github.com/snapframework/cufp2011/blob/master/src/Snap/Chat/ChatRoom...
That's exactly what I would have needed, several times in the past 2 years. I've been wondering about a good way to abstract this to have a library where you'd just plug your "business logic" and thus not have to care anymore about the implementation details, once and for all. I don't have the feeling stm-channelize is the best we can achieve. This really can be made simpler from the user's point of view. -- Alp Mestanogullari