How to avoid stack space overflows?
问题 I've been a bit surprised by GHC throwing stack overflows if I'd need to get value of large list containing memory intensive elements. I did expected GHC has TCO so I'll never meet such situations. To most simplify the case look at the following straightforward implementations of functions returning Fibonacci numbers (taken from HaskellWiki). The goal is to display millionth number. import Data.List # elegant recursive definition fibs = 0 : 1 : zipWith (+) fibs (tail fibs) # a bit tricky