> On Tuesday, 2003-08-19, 13:18, Simon Marlow wrote: > > [...] > > > Yes, I agree that one shouldn't rely on the "no duplication of work" > > property. However, folloing this argument we arrive at the > conclusion that > > hGetContents is an invalid use of unsafePerformIO. (which > is something I've > > been saying for a while now :-). > > Can't hGetContents be implemented without unsafePerformIO but with > unsafeInterleaveIO? Wouldn't this be valid? Am I'm missing > something here?
unsafeInterleaveIO = return . unsafePerformIO Well, almost. unsafeInterleaveIO should also give you the guarantee that the IO in its argument can't be performed *before* the unsafeInterleaveIO is executed, but I don't think this distinction is important to the present discussion. Actually I dislike unsafeInterleaveIO even more than unsafePerformIO, because it has an implicit laziness assumption. The only purpose of unsafeInterleaveIO is to "delay" some IO until it is "demanded". But Haskell lacks a precise definition of "demand", prefering to leave the evaluation order up to the implementation. Hence, unsafeInterleaveIO is left in limbo - it might do something useful, but that depends entirely on your implementation. GHC doesn't guarantee much about unsafeInterleaveIO at all. Cheers, Simon _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell