When I tried the following code in cghi:
take 1 $ take 1 $ repeat [1..]
I was expecting the result of 1
instead of [[1,2,3,4,5,6,7,8,9,10,...
printing on my terminal.
Why is lazy evaluation not functioning as I'm hoping under such situation?
take
is of typeInt -> [a] -> [a]
, i.e. it returns a list. It seems you’re looking forhead
, which returns one element.