2010/7/26 Felipe Lessa <felipe.le...@gmail.com>:
> downloader :: TChan (Maybe Page) -> TChan (Page, Info) -> IO ()
> downloader in out = do
>  mp <- atomically (readTChan in)
>  case mp of
>    Nothing -> return ()
>    Just p -> download p >>= atomically . writeTChan out

Oops!  Of course there should be recursion here!  (This is a bug the
typechecker probably wouldn't catch.)

downloader :: TChan (Maybe Page) -> TChan (Page, Info) -> IO ()
downloader in out = do
 mp <- atomically (readTChan in)
 case mp of
   Nothing -> return ()
   Just p -> download p >>= atomically . writeTChan out >> downloader in out

Cheers,

-- 
Felipe.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to