title: How does Haskell tail recursion work?
body: <p>I wrote this snippet of code and I assume <code>len</code> is tail-recursive, but a stack overflow still occurs. What is wrong?</p>
  
  <pre><code>myLength :: [a] -&gt; Integer
  
  myLength xs = len xs 0
      where len [] l = l
            len (x:xs) l = len xs (l+1)
  
  main = print $ myLength [1..10000000]
  </code></pre>