unsafeInterleaveIO ordering

Robert Ennals Robert.Ennals@cl.cam.ac.uk
Sat, 30 Aug 2003 11:28:07 +0100


[snip]

> If you're using an eager haskell implementation which does some speculative 
> evaluation of things that look cheap and that you might want to evaluate, the 
> answer is probably no.  (Because, having decided to do some speculative work 
> in the absence of a demand, it might decide it has done enough work after the 
> first action, and then later it would finish the job when the result is 
> actually demanded.)

Actually speculative/optimistic evaluation should be fine.

Optimistic Evaluation refuses to speculate IO for exactly this reason. If a 
speculative computation attempts to call unsafePerformIO or evaluate the IO 
from an unsafeInterleaveIO then the speculation is immediately aborted. IO is 
never speculated.

Anyone wanting to find out more about optimistic evaluation is encouraged to 
download the paper from here:

http://www.cl.cam.ac.uk/users/rje33/publications.html



Threads are still an issue, but that can be dealt with using locking.


-Rob