I don't know Haskell, but there is one thing that should still be valid for a functional language: Iteration (loops) can always be replaced by an equivalent recursion or vice versa.
The least confusing definition of
recursion[
^] is a function that calls itself. Each call represents an iteration of the original loop. Endless recursion does not work (it usually ends in a stack overflow), therefore there must be some condition that ends the recursion and simply returns.
For a 'while type' recursion, you would have to test your condition in order to decide wether to execute your function or to return. This is C-like pseudocode:
ReturnType RecursiveFunction(SomeParameters)
{
if(Condition == true)
{
return;
}
else
{
return RecursiveFunction(ModifiedParameters);
}
}
Perhaps this link can help:
Recursion - Learn You a Haskell for Great Good![
^]