16 Feb
2001
16 Feb
'01
6:01 p.m.
I recently wrote:
So, it looks like:
fixIO m = let x = unsafePerformIO (m x) in return x
will do a better job.
But of course, I forgot to make my point before sending the message! The non-strict version is not good either, because it won't do the effects! Consider the definition: fixIO m = let x = unsafePerformIO (m x) in return x and the expression: do { fixIO (\x -> do {putStr "hello"; return (x+1)}); return 2 } We want this to first print hello and then return 2. The non-strict version will return the 2, but will not print the "hello". And the strict version will print the "hello" but won't return the 2. We want both. Hence neither definition is sufficient. -Levent.