I wrote this snippet of code and I assume len is tail-recursive, but a stack overflow still occurs. What is wrong?
myLength :: [a] -> Integer
The foldl carries the same problem; it builds a thunk. You can use foldl' from Data.List to avoid that problem:
import Data.List
myLength = foldl' (const.succ) 0
The only difference between foldl and foldl' is the strict accumulation, so foldl' solves the problem in the same way as the seq and $! examples above. (const.succ) here works the same as (\a b -> a+1), though succ has a less restrictive type.