<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"><<a href="mailto:dons@galois.com">dons@galois.com</a>></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">> a slight modification to compile it :<br>
><br>
> change:<br>
> where sumFile = sum . map read . L.words<br>
> to :<br>
> where sumFile = sum . map (read . L.unpack) . L.words<br>
><br>
> but it's actually _slower_ than the non-bytestring version.<br>
<br>
</div>Never unpack a bytestring.<br>
<br>
import qualified Data.ByteString.Lazy.Char8 as S<br>
<br>
main = print . go 0 =<< S.getContents<br>
where<br>
go n s = case S.readInt s of<br>
Nothing -> n<br>
Just (k,t) -> go (n+k) (S.tail t)<br>
<br>
Assuming you're reading int, integers or doubles.<br>
</blockquote></div><br></div>