<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1400" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>
<P>Hi, </P>
<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
return (res:rs)
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></P>
<P>Is there a better way to implement (possibly infinite) loops in Haskell?
</P></FONT></DIV></BODY></HTML>