[Haskell-cafe] Flattening tail recursion?

Jules Bean jules at jellybean.co.uk
Fri Dec 10 16:37:37 EST 2004


On 10 Dec 2004, at 20:33, GoldPython wrote:

> Just compiled this with -O and it ran with no stack overflow.
> Evidently, no `seq` needed for this one. Using ghc 6.2.2.
>
> countLines l = countLines' 0 l
> countLines' n [] = n
> countLines' n (_:ls) = countLines' (n + 1) ls
>

That's presumably the answer. GHC's strictness analyser *can* cope with 
this situation but only under -O... whereas most of us where testing 
under ghci...

Confirmation from one of the Simons?

Jules



More information about the Haskell-Cafe mailing list