[Haskell-cafe] Different ByteString types

Daniel Fischer daniel.is.fischer at web.de
Wed Aug 18 10:06:04 EDT 2010


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.




More information about the Haskell-Cafe mailing list