
26 Jul
2010
26 Jul
'10
6:29 p.m.
2010/7/26 Felipe Lessa
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.