>> 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
> 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
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>
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