[Haskell-cafe] ReaderT and concurrency

2005-11-16 Thread Kurt Hutchinson
I'm writing a program that will be using multiple threads to handle network activity on multiple ports in a responsive way. The treads will all need access to some shared data, so I'm using an MVar. So far so good. The problem is that passing the MVar around everywhere is kind of a pain, so I was h

Re: [Haskell-cafe] ReaderT and concurrency

2005-11-16 Thread Andrew Pimlott
On Wed, Nov 16, 2005 at 11:51:19AM -0500, Kurt Hutchinson wrote: > I have to perform another runReaderT when forking? Or is there a way > to get the ReaderT environment automatically carried over to the newly > created Set B thread? This is an unavoidable pain as far as I know. It would be nice i

Re: [Haskell-cafe] ReaderT and concurrency

2005-11-16 Thread Tomasz Zielonka
On Wed, Nov 16, 2005 at 09:45:17AM -0800, Andrew Pimlott wrote: > On Wed, Nov 16, 2005 at 11:51:19AM -0500, Kurt Hutchinson wrote: > > I have to perform another runReaderT when forking? Or is there a way > > to get the ReaderT environment automatically carried over to the newly > > created Set B th

Re: [Haskell-cafe] ReaderT and concurrency

2005-11-16 Thread Andrew Pimlott
On Wed, Nov 16, 2005 at 07:20:48PM +0100, Tomasz Zielonka wrote: > On Wed, Nov 16, 2005 at 09:45:17AM -0800, Andrew Pimlott wrote: > > On Wed, Nov 16, 2005 at 11:51:19AM -0500, Kurt Hutchinson wrote: > > > I have to perform another runReaderT when forking? Or is there a way > > > to get the ReaderT

Re: [Haskell-cafe] ReaderT and concurrency

2005-11-16 Thread Tomasz Zielonka
On Wed, Nov 16, 2005 at 10:53:17AM -0800, Andrew Pimlott wrote: > On Wed, Nov 16, 2005 at 07:20:48PM +0100, Tomasz Zielonka wrote: > > I think it wouldn't be possible using only methods in MonadIO. > > Here's what I had in mind for forkProcess. Recall that the fork syscall > returns 0 to the chil

Re: [Haskell-cafe] ReaderT and concurrency

2005-11-16 Thread Bulat Ziganshin
Hello Kurt, Wednesday, November 16, 2005, 7:51:19 PM, you wrote: KH> I'm writing a program that will be using multiple threads to handle KH> network activity on multiple ports in a responsive way. The treads KH> will all need access to some shared data, so I'm using an MVar. So far KH> so good. T

Re: [Haskell-cafe] ReaderT and concurrency

2005-11-16 Thread Thomas Jäger
Kurt, There are basically two ways of doing that, namely monad transformers and implicit parameters (we actually use both techniques in lambdabot). Implicit parameters save you a lot of conversions or explicit passing of variables because you only need one monad (the IO monad); however they are gh