Lazy IO?

Sengan.Baring-Gould@nsc.com Sengan.Baring-Gould@nsc.com
Tue, 3 Sep 2002 15:06:44 -0400


On Tue, 3 Sep 2002 20:08:32 +0100
"Duncan Coutts" <duncan@coutts.uklinux.net> wrote:

> On Tue, 3 Sep 2002 14:49:45 -0400
> Sengan.Baring-Gould@nsc.com wrote:
> 
> > Is there any way to make the IO Monad lazy?
> > 
> > The simplified version of my problem is that I want to
> > generate an infinite structure from an IOArray and then
> > consume only the relevant part of it.
> 
> Yes, unsafeInterleaveIO.
> 
> http://www.haskell.org/ghc/docs/latest/html/base/System.IO.Unsafe.html#unsafeInterleaveIO
> 
> This is how getContents is implemented so that it reads the file lazily.
> 
> Be careful of course it is "unsafe".
> 
> Duncan

Excellent.

Thanks a lot,

Sengan