[Haskell-beginners] Avoiding stack space overflow