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

wagnerdm at seas.upenn.edu wagnerdm at seas.upenn.edu
Mon Jan 23 21:31:01 CET 2012


Quoting Heka Treep <zena.treep at 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 $ atomically (readTChan mbox) >>= putStrLn

~d



More information about the Glasgow-haskell-users mailing list