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

Peter Gammie peteg42 at gmail.com
Fri Dec 28 06:13:34 EST 2007

On 28/12/2007, at 5:50 PM, Miguel Mitrofanov wrote:

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

I'll bite. So what do you expect:

take 5 [1,2,3,4,5,undefined]

to do? How about:

take 5 (1:2:3:4:undefined)


So it does seem to matter how much of the list it evaluates...

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

I defined it - I'm interested in things that are observationally  
equivalent. Please read the generalised-take-lemma paper. It will  
clear up some of this confusion.


More information about the Haskell-Cafe mailing list