Funky haskell lazy list implicit recursion
In Haskell, you can build infinite lists due to laziness: Prelude> let g = 4 : g Prelude> g !! 0 4 Prelude> take 10 g [4,4,4,4,4,4,4,4,4,4] Now, what exactly goes on when I try to construct a list like this? Prelude> let f = f !! 10 : f Prelude> f !! 0 Interrupted. Prelude> take 10 f [Interrupted. Prelude> The Interrupted. s are me hitting CTRL+C after waiting a few seconds. It seems to go into an infinite loop, but why is that the case? Explanation for non-Haskellers: The : operator is prepend : Prelude> 4 : [1, 2, 3] [4,1,2,3] This line: Prelude> let g = 4 : g says "let g be the list