<div dir="ltr">the problem is that using readInt is actually _as slow_, at least using my test script :-((<br><br><div class="gmail_quote">On Tue, Oct 7, 2008 at 5:12 AM, Don Stewart <span dir="ltr">&lt;<a href="mailto:dons@galois.com">dons@galois.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">666wman:<br>
<div class="Ih2E3d">&gt; &nbsp; &nbsp;a slight modification to compile it :<br>
&gt;<br>
&gt; &nbsp; &nbsp;change:<br>
&gt; &nbsp; &nbsp;where sumFile = sum . map read . L.words<br>
&gt; &nbsp; &nbsp;to :<br>
&gt; &nbsp; &nbsp;where sumFile = sum . map (read . L.unpack) . L.words<br>
&gt;<br>
&gt; &nbsp; &nbsp;but it&#39;s actually _slower_ than the non-bytestring version.<br>
<br>
</div>Never unpack a bytestring.<br>
<br>
 &nbsp; &nbsp;import qualified Data.ByteString.Lazy.Char8 as S<br>
<br>
 &nbsp; &nbsp;main = print . go 0 =&lt;&lt; S.getContents<br>
 &nbsp; &nbsp; &nbsp;where<br>
 &nbsp; &nbsp; &nbsp; &nbsp;go n s = case S.readInt s of<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Nothing &nbsp; &nbsp; -&gt; n<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Just (k,t) &nbsp;-&gt; go (n+k) (S.tail t)<br>
<br>
Assuming you&#39;re reading int, integers or doubles.<br>
</blockquote></div><br></div>