[Haskell-cafe] How to implement nested loops with tail recursion?