[Haskell-cafe] Lazy Lists and IO

Andrew Coppin andrewcoppin at btinternet.com
Thu Jul 12 14:08:27 EDT 2007


Derek Elkins wrote:
> On Wed, 2007-07-11 at 22:33 +0200, Chaddaï Fouché wrote:
>   
>> 2007/7/11, Andrew Coppin <andrewcoppin at btinternet.com>:
>>     
>>> Ouch! That's gotta sting...
>>>
>>> I wasn't aware that this function was so leathal. I use it constantly
>>> all the time...
>>>
>>>       
>> It isn't that "lethal" usually. It's only because he was using it on
>> an infinite stream that it hurt so much... If you use it on a normal
>> stdin or a hGetContents on a file it will be fine (though you will
>> lose the advantage of its laziness, for example constant memory
>> treatment).
>>
>>     
>
> Nevertheless, length is a function you should rarely use.
>   

Amen.

(I believe the Wiki mentions this concept somewhere... Maybe we should 
rename it unsafeLength? No, OK, how about... um... slowLength?)



More information about the Haskell-Cafe mailing list