RE: [Haskell] Files and lazyness

2005-08-02 Thread Simon Marlow
On 01 August 2005 16:05, Cale Gibbard wrote: > Your problem is, as you pointed out, that readFile does lazy IO. > Although the semantics of it can be a bit confusing at times, it is > useful for applications where you have a large file which is being > consumed, and you don't want to allocate all

Re: [Haskell] Files and lazyness

2005-08-01 Thread Wolfgang Jeltsch
Am Montag, 1. August 2005 22:38 schrieb Tomasz Zielonka: > On Thu, Jul 28, 2005 at 08:01:17PM +0200, Diego y tal wrote: > [...] > > but.. is it normal that we have to think about this "problem" when > > programming? > > You just have to know, which functions mix laziness and side-effects > by usin

Re: [Haskell] Files and lazyness

2005-08-01 Thread Tomasz Zielonka
On Thu, Jul 28, 2005 at 08:01:17PM +0200, Diego y tal wrote: > I understand that this is caused by the lazyness, No, it is caused by mixing laziness with side-effects, which happens when you use getContents/readFile. > that doesn't evaluate the expression "x <- readFile fEntrada" until > it's nec

Re: [Haskell] Files and lazyness

2005-08-01 Thread Wolfgang Jeltsch
Am Donnerstag, 28. Juli 2005 20:01 schrieb Diego y tal: > I was developing a web site using haskell programs as cgi's, and I found > a strange behavior that I would like to know whether it is normal. I > have reduced the "problem" to the next program: > > fEntrada = "fich.txt" > fSalida = "fich.txt

Re: [Haskell] Files and lazyness

2005-08-01 Thread Cale Gibbard
Your problem is, as you pointed out, that readFile does lazy IO. Although the semantics of it can be a bit confusing at times, it is useful for applications where you have a large file which is being consumed, and you don't want to allocate all of the memory for it before doing any processing. Lazi