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"]
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe