<div>Hi Stephen,<br></div><div><br></div><div>Thanks for the answer, I shall give it a go later tonight (UK time).</div><div><br></div><div>Why would I want to keep my functions monadic? It's not that I'm against the idea, rather it's that I don't understand the choice. I was under the (possibly wrong) impression that (IO) monadic functions were just to "get around" the issue of side-effects and that where possible functions should be coded outside of monads. Is that just plain wrong, or does it boil down to "It depends on what you're doing, and in this case..."?</div>
<div><br></div><div>Also I think I've already encountered the hidden Data.Binary problem in GHC. I have got around it already by (if memory serves) starting GHC and telling it to ignore it's own Data.Binary so I can then include it in my own projects. But I created an alias which starts this Data.Binary-capable GHC and I can't remember what's behind it now!</div>
<div><br></div><div>What's the reason for GHC hiding packages and preventing them from being imported/used in loaded projects?</div><div><br></div><div>Thanks again for the help.</div><div><br></div><div>Tom</div><br>
<div class="gmail_quote">On Tue, Jun 15, 2010 at 9:15 PM, Stephen Tetley <span dir="ltr"><<a href="mailto:stephen.tetley@gmail.com">stephen.tetley@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Tom<br>
<br>
Try ...<br>
<br>
extractInt :: [Word8] -> Int<br>
<div class="im">extractInt = foldl addDigit 0<br>
where<br>
</div> addDigit num d = 10*num + (fromIntegral d)<br>
<br>
<br>
You might find you want to keep your functions monadic, and mostly use<br>
the Get monad from the module Data.Binary.Get for working with binary<br>
data.For instance there is a function getWord32be to do the work that<br>
extractInt is doing<br>
<br>
Best wishes<br>
<font color="#888888"><br>
Stephen<br>
</font></blockquote></div><br>