Re: [Haskell-cafe] Strictness leak

2007-10-31 Thread Ketil Malde
Jeff Polakow [EMAIL PROTECTED] writes: Besides anything else, sequence will diverge on an infinite list. Argh, of course. Thanks! It is necessary to compute all of the computations in the list before returning any of the pure resulting list. Replacing sequence with sequence', given as:

[Haskell-cafe] Strictness leak

2007-10-30 Thread Ketil Malde
Some time ago, I posted this code: countIO :: String - String - Int - [a] - IO [a] countIO msg post step xs = sequence $ map unsafeInterleaveIO ((blank outmsg (0::Int) c):cs) where (c:cs) = ct 0 xs output = hPutStr stderr blank= output ('\r':take 70 (repeat '

Re: [Haskell-cafe] Strictness leak

2007-10-30 Thread Jeff Polakow
Hello, countIO :: String - String - Int - [a] - IO [a] countIO msg post step xs = sequence $ map unsafeInterleaveIO ((blank outmsg (0::Int) c):cs) where (c:cs) = ct 0 xs output = hPutStr stderr blank= output ('\r':take 70 (repeat ' ')) outmsg x

Re: [Haskell-cafe] Strictness leak

2007-10-30 Thread Emil Axelsson
You mean for the IO monad, right? take 10 $ execWriter $ sequence $ repeat $ tell ([3]::[Int]) / Emil On 10/30/2007 02:04 PM, Jeff Polakow wrote: Hello, countIO :: String - String - Int - [a] - IO [a] countIO msg post step xs = sequence $ map unsafeInterleaveIO ((blank outmsg

Re: [Haskell-cafe] Strictness leak

2007-10-30 Thread Jeff Polakow
I forgot to send this reponse to haskell-cafe earlier... Hello, You mean for the IO monad, right? Sorry. I meant divergence is unavoidable for any strict Monad, such as IO. However, sequence will always compute over the entire list; if the resulting computation itself is lazy then the