Re: Is it true that an exception is always terminates the thread?

2012-01-26 Thread wren ng thornton
On 1/23/12 3:19 PM, Edward Z. Yang wrote: Excerpts from Heka Treep's message of Mon Jan 23 15:11:51 -0500 2012: actor mbox = do empty- atomically $ isEmptyTChan mbox if empty then actor mbox else do val- atomically $ readTChan mbox Uh, don't you want to combine

Re: Is it true that an exception is always terminates the thread?

2012-01-26 Thread wren ng thornton
On 1/24/12 10:25 AM, Ryan Newton wrote: This is related but somewhat tangential -- *Why isn't there a tryReadChan?* It looks like it would be implementable with the current Chan representation in terms of tryTakeMVar. Especially since isEmptyChan is deprecated this would be nice to have.

Re: Is it true that an exception is always terminates the thread?

2012-01-26 Thread wren ng thornton
On 1/26/12 10:01 PM, wren ng thornton wrote: On 1/24/12 10:25 AM, Ryan Newton wrote: This is related but somewhat tangential -- *Why isn't there a tryReadChan?* It looks like it would be implementable with the current Chan representation in terms of tryTakeMVar. Especially since isEmptyChan is

Re: Is it true that an exception is always terminates the thread?

2012-01-25 Thread Simon Marlow
On 24/01/2012 15:59, Edward Z. Yang wrote: Excerpts from Ryan Newton's message of Tue Jan 24 10:25:37 -0500 2012: This is related but somewhat tangential -- *Why isn't there a tryReadChan?* It looks like it would be implementable with the current Chan representation in terms of

Re: Is it true that an exception is always terminates the thread?

2012-01-24 Thread John Lato
From: Heka Treep zena.tr...@gmail.com Subject: Re: Is it true that an exception is always terminates the        thread? To: Edward Z. Yang ezy...@mit.edu Cc: glasgow-haskell-users glasgow-haskell-users@haskell.org Message-ID:        

Re: Is it true that an exception is always terminates the thread?

2012-01-23 Thread Edward Z. Yang
Excerpts from Heka Treep's message of Mon Jan 23 13:56:47 -0500 2012: adding the message queue (with Chan, MVar or STM) for each process will not help in this kind of imitation. Why not? Instead of returning a thread ID, send the write end of a Chan which the thread is waiting on. You can send

Re: Is it true that an exception is always terminates the thread?

2012-01-23 Thread Heka Treep
2012/1/23, Edward Z. Yang ezy...@mit.edu: Excerpts from Heka Treep's message of Mon Jan 23 13:56:47 -0500 2012: adding the message queue (with Chan, MVar or STM) for each process will not help in this kind of imitation. Why not? Instead of returning a thread ID, send the write end of a Chan

Re: Is it true that an exception is always terminates the thread?

2012-01-23 Thread Edward Z. Yang
Excerpts from Heka Treep's message of Mon Jan 23 15:11:51 -0500 2012: import Control.Monad.STM import Control.Concurrent import Control.Concurrent.STM.TChan spawn f = do mbox - newTChanIO forkIO $ f mbox

Re: Is it true that an exception is always terminates the thread?

2012-01-23 Thread wagnerdm
Quoting Heka Treep zena.tr...@gmail.com: actor mbox = do empty - atomically $ isEmptyTChan mbox if empty then actor mbox else do val - atomically $ readTChan mbox putStrLn val actor mbox This looks a bit silly. Why not just this? actor mbox = forever $

Re: Is it true that an exception is always terminates the thread?

2012-01-23 Thread Heka Treep
2012/1/23, Edward Z. Yang ezy...@mit.edu: Excerpts from Heka Treep's message of Mon Jan 23 15:11:51 -0500 2012: import Control.Monad.STM import Control.Concurrent import Control.Concurrent.STM.TChan spawn f =

Re: Is it true that an exception is always terminates the thread?

2012-01-23 Thread Edward Z. Yang
Excerpts from Heka Treep's message of Mon Jan 23 16:20:51 -0500 2012: actor :: TChan String - IO () actor mbox = forever $ do putStrLn call to actor... msg - atomically $ do isEmpty - isEmptyTChan mbox if isEmpty then return Nothing else readTChan mbox = return . Just when