He Daniel,<br><br><br>Cool, I just found out the same with the profiler. I have removed the state entirely (it is not really neccesary) and it results in a speedup of 10x. Storing the instructions in an array instead of an list speeded also things up. <br>
<br>But I will test the original with State.Strict and see how it will perform.<br><br>Thanks,<br><br>Edgar<br><br><br><div class="gmail_quote">2010/1/21 Daniel Fischer <span dir="ltr"><<a href="mailto:daniel.is.fischer@web.de">daniel.is.fischer@web.de</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Am Mittwoch 20 Januar 2010 16:45:41 schrieb Edgar Klerks:<br>
<div><div></div><div class="h5">> Hello,<br>
><br>
> I just started using haskell and found it many uses for it (mainly for<br>
> scripting purposes at the moment). Now, I have written a brainfuck<br>
> parser and interpreter in haskell, but it produces a stack overflow if<br>
> the program runs too long and I don't understand why. I thought I made<br>
> the interpreter loop tail recursive, which I understood is the most<br>
> common cause of a stack overflow. Can someone help my find my fault? I<br>
> somehow miss something. I added the program as attachment.<br>
><br>
> Thanks for your help.<br>
><br>
> With kind regards,<br>
><br>
> Edgar Klerks<br>
<br>
</div></div>A quick look revealed that you use Control.Monad.State, which defaults to<br>
Control.Monad.State.Lazy. That is very often too lazy for longer<br>
calculations and produces a stack overflow.<br>
Maybe changing the import to Control.Monad.State.Strict helps (that isn't<br>
entirely strict either, but often reduces the opportunities for building<br>
large thunks sufficiently).<br>
</blockquote></div><br>