[Haskell-beginners] Brainfuck interpreter stack overflow

Edgar Klerks edgar at goodforall.eu
Fri Jan 22 08:33:27 EST 2010


Thanks for your help Stephen and Daniel. The interpreter now doesn't
show any stackoverflows anymore. By using the profiler, I identified
some problems. The State Monad seemed to cause a memory leak. It also
made the interpreter run slow. I removed it, because it isn't neccesary.
I also used Immutable Arrays to store the instructions in, which seemed
to speed it also up. I made the code more functional and the evaluation
loop tail-recursive, which helped a lot. 

I am now testing different storage models for the data tape. I now use
Data.Map, but Data.Zipper.List maybe more appropiate. 

I didn't know about the profiler and I am suprised it is such a big
help. I never used one before. 

Best Wishes,

Edgar



More information about the Beginners mailing list