Different ByteString types

L.S., I hope someone can help me with the following: I am trying to check the SHA1 hash of a file, using the package cryptohash [0]; the following error message is displayed when I try to compile my program: SHA1check.lhs:35:32: Couldn't match expected type `B.ByteString' against inferred type `Data.ByteString.Internal.ByteString' In the second argument of `(.)', namely `hashlazy' In the second argument of `(.)', namely `B.unpack . hashlazy' In the first argument of `(<$>)', namely `show . B.unpack . hashlazy' The relevant lines of code are:
import qualified Data.ByteString.Lazy as B import Data.CryptoHash.SHA1 ( hashlazy )
hash <- show . B.unpack . hashlazy <$> B.hGetContents h
There is only one version of the bytestring package installed. Details: - Windows XP - bytestring-0.9.1.7 - cryptohash-0.5.1 - Haskell Platform 2010.2.0.0 Regards, Henk-Jan van Tuyl P.S. A patch is needed if you want to install cryptohash with MinGW [0] http://hackage.haskell.org/package/cryptohash -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html --

On Wednesday 18 August 2010 16:00:41, Henk-Jan van Tuyl wrote:
L.S.,
I hope someone can help me with the following: I am trying to check the SHA1 hash of a file, using the package cryptohash [0]; the following error message is displayed when I try to compile my program:
SHA1check.lhs:35:32: Couldn't match expected type `B.ByteString' against inferred type `Data.ByteString.Internal.ByteString' In the second argument of `(.)', namely `hashlazy' In the second argument of `(.)', namely `B.unpack . hashlazy' In the first argument of `(<$>)', namely `show . B.unpack . hashlazy'
The relevant lines of code are:
import qualified Data.ByteString.Lazy as B import Data.CryptoHash.SHA1 ( hashlazy )
hash <- show . B.unpack . hashlazy <$> B.hGetContents h
There is only one version of the bytestring package installed.
The result of hashlazy is a *strict* ByteString, so you'd need Data.ByteString.unpack instead of B.unpack.
participants (2)
-
Daniel Fischer
-
Henk-Jan van Tuyl