I didn&#39;t compile, but, by the looks of it, I would change <br><br>import qualified Data.ByteString as BS (readFile)<br><br>for<br><br>import qualified Data.ByteString.Lazy as BS (readFile)<br><br><br>as it seems sha1 needs a lazy bytestring<br>
<br><div class="gmail_quote">On Thu, Jan 29, 2009 at 13:25, emmanuel.delaborde <span dir="ltr">&lt;<a href="mailto:emmanuel.delaborde@cimex.com">emmanuel.delaborde@cimex.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;">
Hello<br>
<br>
I have the following snippet :<br>
<br>
----------------------------------------------------------<br>
<br>
module Main where<br>
<br>
import System.Environment (getArgs)<br>
import Data.Digest.OpenSSL.MD5 (md5sum)<br>
import Data.Digest.Pure.SHA (sha1, showDigest)<br>
import qualified Data.ByteString as BS (readFile)<br>
<br>
-- sha1 :: ByteString -&gt; Digest<br>
-- readFile :: FilePath -&gt; IO ByteString<br>
-- md5sum :: ByteString -&gt; String<br>
-- showDigest :: Digest -&gt; String<br>
<br>
checkHash :: String -&gt; String -&gt; String -&gt; IO ()<br>
checkHash codec hash file =<br>
 &nbsp;let f = case codec of<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--&quot;md5&quot; &nbsp;-&gt; md5sum<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot;sha1&quot; -&gt; showDigest . sha1<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_ &nbsp; &nbsp; &nbsp;-&gt; error &quot;Codec must be md5 or sha1 !&quot; in<br>
 &nbsp;BS.readFile file &gt;&gt;= \fileBS -&gt;<br>
 &nbsp;let fileHash = f fileBS in<br>
 &nbsp;print (hash == fileHash)<br>
<br>
main =<br>
 &nbsp;getArgs &gt;&gt;= \as -&gt;<br>
 &nbsp;case as of<br>
 &nbsp; &nbsp;(codec:hash:file:_) -&gt; checkHash codec hash file<br>
 &nbsp; &nbsp;_ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; usage<br>
<br>
usage = print &quot;checksum codec hash file&quot;<br>
<br>
----------------------------------------------------------<br>
<br>
which fails to compile, this is the error I get :<br>
<br>
<br>
checksum.hs:20:19:<br>
 &nbsp; &nbsp;Couldn&#39;t match expected type `Data.ByteString.Lazy.Internal.ByteString&#39;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; against inferred type `Data.ByteString.Internal.ByteString&#39;<br>
 &nbsp; &nbsp;In the first argument of `f&#39;, namely `fileBS&#39;<br>
 &nbsp; &nbsp;In the expression: f fileBS<br>
 &nbsp; &nbsp;In the definition of `fileHash&#39;: fileHash = f fileBS<br>
<br>
<br>
<br>
<br>
it looks like &nbsp;(showDigest . sha1) expects Data.ByteString.Lazy.Internal.ByteString but gets Data.ByteString.Internal.ByteString<br>
<br>
What can I do ?<br>
<br>
Thanks<br>
<br>
E.<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
-----------------------------------------------------------------------------------------------<br>
<br>
This e-mail (and any attachments) is confidential and may containpersonal views which are not the views of Cimex Media Ltd andany affiliated companies, unless specifically stated. It is intendedfor the use of the individual or group to whom it is addressed. Ifyou have received it in error, please delete it from your system,do not use, copy or disclose the information in any way nor act inreliance on it and please notify <a href="mailto:postmaster@cimex.com" target="_blank">postmaster@cimex.com</a><br>

<br>
A company registered in England &nbsp;Wales. Company Number 03765711<br>
Registered Office : The Olde Bakehouse, 156 Watling Street East, Towcester,<br>
Northants NN12 6DB<br>
<br>
This email was scanned by Postini, the leading provider in Managed Email Security.<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Rafael Gustavo da Cunha Pereira Pinto<br>Electronic Engineer, MSc.<br>