
24 Feb
2010
24 Feb
'10
3:38 p.m.
Hi Fabian You need to yield with unsafeInterleaveIO to allow some of the list to be be consumed. Something like this (which never terminates of course, but do produce output): import System.IO.Unsafe import Control.Monad main = do messages <- readLazy mapM_ (\x -> putStr $ show x ++ "\n") $ messages return () where readLazy :: IO [String] readLazy = unsafeInterleaveIO $ do { c <- fancyIORead ; liftM2 (++) (return c) readLazy } fancyIORead :: IO [String] fancyIORead = return ["aa","bb"]