
Hi fellow Haskellers! Trying literary style here, lets just hope it plays well with your email clients. Suppose we define a list - somewhat arbitrarily - as
xs = [1..42] :: [Int]
Next, we let x and ys be
x = 17 -- also somewhat arbitrarily ys = [ y | y <- xs, y >= x ]
My question: in which WHNF state is ys? y and x are evaluated in applying >= to them - at least in this particular instance of Ord (Int). Are these evaluated values then copied to the new list ys, or are they just stored as thunks? I would guess that they are just thunked, and that the state of ys is [*thunk*,*thunk*,...,*thunk*] since it cannot be known beforehand to what extent the predicate reduces its arguments (in this case >= ), but I don't know for sure. I thought I had sufficient knowledge about thunks, WHNF, NF and lazy evaluation, but this one does me in. I guess it is because I haven't trawled through Okasaki's book yet :)