[Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked?

Manlio Perillo manlio_perillo at libero.it
Mon Mar 2 07:40:32 EST 2009

Bayley, Alistair ha scritto:
>> From: haskell-cafe-bounces at haskell.org 
>> [mailto:haskell-cafe-bounces at haskell.org] On Behalf Of Manlio Perillo
>> Sent: 02 March 2009 11:01
>> Eugene Kirpichov ha scritto:
>>> I'm not considering the lazy IO approach, as it doesn't involve any
>>> form of control over resources.
>> This is not always true.
>> I'm using lazy IO, still having full control over the resources.
>> parse path = withFile path ReadMode parse'
>>      where
>>        parse' :: Handle -> IO (UArr Xxx)
>>        parse' handle = do
>>          contents <- L.hGetContents handle
>>          let v = toU $ xxx $ L.lines contents
>>          rnf v `seq` return v
>> All the file is consumed, before the result is returned.
> This only works if the entire file can reasonably fit into memory. 

It's not the entire file, but only the parsed data structure.

> If you want to process something really big, then you need some sort of streaming approach, 

Yes, this is a more general solution.

 > [...]

Manlio Perillo

More information about the Haskell-Cafe mailing list