Re: How to write a lazy variant ?

2001-12-05 Thread Dmitry Astapov
>> I hate to followup to myself, but looks like I had to. I really was >> too tired and lazy version could be obtained by simple use of >> accumulator: ADR> Are you _sure_ that's all it takes? Well, I cannot be 100% sure, but what I observe in ghci is that evaluating 'recs <- readRecordFile "so

Re: How to write a lazy variant ?

2001-12-04 Thread Alastair David Reid
> I hate to followup to myself, but looks like I had to. I really was > too tired and lazy version could be obtained by simple use of > accumulator: Are you _sure_ that's all it takes? I was expecting that you'd need 'unsafeInterleaveIO'. (This function is used to implement hGetContents. Some

Re: How to write a lazy variant ?

2001-12-04 Thread Dmitry Astapov
DA> Consider the following functions: DA> readRecFile fname = DA> do ifh <- openFile fname ReadMode DA>readRecords ifh DA> readRecords ifh = DA> do x <- decodeNextRecord ifh DA>more <- isEof ifh DA>if (more == False) DA> then return [x] DA>

How to write a lazy variant ?

2001-12-04 Thread Dmitry Astapov
Consider the following functions: readRecFile fname = do ifh <- openFile fname ReadMode readRecords ifh readRecords ifh = do x <- decodeNextRecord ifh more <- isEof ifh if (more == False) then return [x] else do rest <- readRecords ifh