IO monad and lazy evaluation

Graham Klyne GK@ninebynine.org
Thu, 22 May 2003 10:22:57 +0100


Hal,

Thanks for your comments.  (I had overlooked "readFile", which certainly 
looks safer.  I'm not yet fully used to the distribution of functions 
between standard libraries and the Prelude.  As for my 'hSafeGetContents', 
I realized exactly your point about using 'id' too late, after I'd sent my 
email. :-(  )

The broader debate I was trying to evoke was:  how, as a programmer using a 
combination of monads and non-strict functions, can I be confident that 
there aren't hidden interactions waiting to bite?

Using the hOpen ... hClose vs readFile case as an example, is the 
difficulty here to do with the interleaving of multiple statements that 
modify some state with non-strict functions that return results based on 
some particular instance of that state?  Is this really a fundamental mismatch?

I read recently that other functional languages (ML?) with strict 
evaluation semantics can be used to mimic lazy evaluation, but saw no clue 
how that would work.  I'm wondering if any insight might be gained by 
looking at how such mechanisms might interact with functional 
state-transformer mechanisms?

#g
--

[I'm aware this discussion thread is starting to run on a bit... is it 
on-topic for this list?]


-------------------
Graham Klyne
<GK@NineByNine.org>
PGP: 0FAA 69FF C083 000B A2E9  A131 01B9 1C7A DBCA CB5E