[Haskell-cafe] Re: Wikipedia on first-class object

Miguel Mitrofanov miguelimo38 at yandex.ru
Fri Dec 28 05:50:21 EST 2007


> Right, so when I say to GHCi:
> Prelude> take 5 [1..]
> and it says:
> [1,2,3,4,5]
> then it really has computed the entirety of the infinite sequence  
> [1..], and not some approximation?

Of course not! In fact, it doesn't even compute the value "1". It just juggles with the bytes somehow, so that it seems that it computes the whole sequence and then applies "take 5". But does it really matter if it computes 5 integers, or 10, or the whole sequence, at least if we are not concerned about performance?

> Perhaps it is better to say that in a lazy language both  
> approximations and maximal values (least upper bounds of a chain) are  
> interesting.

Well, that depends of your notion of interesting.


More information about the Haskell-Cafe mailing list