On Fri, 2 Jan 2009, Achim Schneider wrote:
Henning Thielemann <[email protected]> wrote:
If it is generally possible to use unsafeInterleaveIO such that it
executes actions in the right order, wouldn't this allow the
definition of a general lazy IO monad?
The question is what "right order" means.
Let B1..Bn be some arbitrary IO-Actions.
Let A1..An be some arbitrary IO Actions passed to unsafeInterleaveIO
You're guaranteed that
a) Bk+1 is executed after Bk
b) Ak+1 is executed after Ak
, all by virtue of the IO Monad.
If all Ak's are defered using individual unsafeInterleaveIO's then it is
not guaranteed that A[k+1] is executed after A[k]. That's my problem.
Check:
Prelude> fmap snd $ Monad.liftM2 (,) (unsafeInterleaveIO getLine)
(unsafeInterleaveIO getLine)
If unsafely interleaved actions would be executed in order, then this
would first ask you for the first pair member, then for the second one,
then echo the second one. Actually it asks only for the second one and
prints it.
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe