[Haskell-cafe] Binary serialization, was Re: Abstraction leak

Paul Moore p.f.moore at gmail.com
Thu Jul 5 12:39:58 EDT 2007


On 05/07/07, Paul Moore <p.f.moore at gmail.com> wrote:
> The need I had for these is no longer current, but sometime I'll try
> an experiment and see how easy it is, on a relatively clean Windows
> box with just GHC installed, to grab and use these libraries.

Just for fun I had a go with crypto:

- Found crypto 3.0.3 on hackage.
- Tried to build, it depends on NewBinary
- Found that on hackage, downloaded and built OK. Lots of scary
warnings about happy, greencard etc, not being found during configure,
but let's go on.
- Installed NewBinary as I didn't know how to make crypto find it
without installing it. I'm a bit nervous, as I don't know how to
*un*install it after I've finished. And it installed to my C drive,
where I'd really rather it went somewhere else. There is probably
documentation on how to do this, but remember, all I really want to do
is to write a tiny program to get the MD5 checksum of a file.

Ah, well. Carry on.

- crypto builds and installs OK. But where are the docs? Not installed
anywhere obvious, not on hackage. Try google.
- Found the crypto website, but aargh! It looks like 3.0.3 is out of
date and there's a 4.x available. Never mind, that's not likely to
have changed.
- But no simple examples, and the haddoc docs show APIs, but not usage examples!

Going for the obvious approach:

import System.IO
import Data.Digest.MD5

main = do
    h <- openBinaryFile "md5.hs" ReadMode
    s <- hGetContents h
    hClose h
    md5 <- hash s

No surprise, this doesn't work. After all, hash wants [Octet], not String.

OK, I know this is now getting beyond library availability. But it
doesn't compare well to Python's "I want an md5 checksum of a file -
check the docs, there's a library function built in, use it, no
problems".

I see you've already responded, and we're in broad agreement. So I
won't labour the point. It's an infrastructure issue rather than a
technical one, and it *will* improve. What will be interesting is how
much the generally lousy Windows experience can be improved - as
Duncan points out, installing development libraries on Windows,
whether Haskell or C, is a hugely irritating pain. If no-one has found
a good answer for C in all these years, it would be great if Haskell
could even do slightly better :-)

Regards,
Paul.


More information about the Haskell-Cafe mailing list