I will suggest an analogy to a similar (but simpler) situation.

Suppose you are adding up some numbers.

foo = let { x = 3; y = 4; z = 5 } in x + y + z

That pattern only works if you know in advance how many numbers you are going to add.

Otherwise, you need a function that works on a whole list of numbers:

sum = foldr (+) 0

So...the short answer to your question is: use recursion. The better answer is: use library functions that do the recursion for you. You might want to look at foldM:

http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Monad.html#v:foldM

-Karl