2009/4/2  <span dir="ltr">&lt;<a href="mailto:lucas@die.net.au">lucas@die.net.au</a>&gt;</span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I&#39;m relatively new to haskell so as one does, I am rewriting an<br>
existing program in haskell to help learn the language.<br>
<br>
However, it eats up all my RAM whenever I run the program.<br>
<br>
<a href="http://hpaste.org/fastcgi/hpaste.fcgi/view?id=3175#a3175" target="_blank">http://hpaste.org/fastcgi/hpaste.fcgi/view?id=3175#a3175</a><br>
<br>
Obviously I&#39;m doing something wrong, but without my magical FP pants I<br>
don&#39;t know what that might be.</blockquote><div><br>(1) You are using plain Strings.  Those things are like 8 bytes per character (or something, someone more knowledgeable can give a more accurate figure).  Use bytestrings (with bytestring-utf8 if you need it) instead.<br>
<br>(2) You are parsing strictly, meaning you have to read the whole input file before anything can be output.  This may be necessary for your application, but Haskell is <i>very</i> strong with streaming applications.  Change to a lazy parser and you will run in constant memory.<br>
<br>(I don&#39;t know offhand of any lazy parsing libraries, but I&#39;ve heard them discussed before, so they&#39;re somewhere)<br><br>Luke<br></div></div><br>