<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1400" name=GENERATOR>
<P>I've implemented a Neural Net simulator which needs to repeat a training loop
many times. For this I used a while function: <PRE>while test body = do
(cond,res) <- body
if (test cond) then do rs <- while test body
else return [res]
</PRE>However, when I run the program, the interpreter falls over after a few
thousand iterations, running out of space. I think that this is because the
Monadic implementation of the while loop actually nests functions of type (a
-> M b) and there is a maximum ?stack size.
<P>Is there a better way to implement (possibly infinite) loops in Haskell?