[Haskell-cafe] Just for a laugh...
Donald Bruce Stewart
dons at cse.unsw.edu.au
Fri Jun 1 22:21:46 EDT 2007
> Donald Bruce Stewart wrote:
> >See also the older NewBinary,
> > http://hackage.haskell.org/cgi-bin/hackage-scripts/package/NewBinary-0.1
> Now that's just ironic...
> Incidentally, I've been thinking. You *might* want the binary
> representation of things if you were going to, say, compress or encrypt
> data before putting it into a file or whatever. Actually in Java
> (bleeeh) you can wrap things around a stream so that data gets
> compressed and transformed between where the program writes it, and
> where it hits the endpoint. Haskell doesn't have a library for this, and
> I don't immediately see how to implement one. It would be darn useful to
> have a standard setup for this though. That way, when somebody wants to
> implement a new way to do zlib compression or a SHA-256 implementation
> or... there will already be a standardised way to access the binary
> representation of data without having to write it to a file.
> (If any of that made sense...)?)
Our zlib and bzlib2 bindings operate on in-memory lazy bytestrings.
They thus provide:
compress :: ByteString -> ByteString
and its inverse. So you can chain them with decoding:
writeFile "foo.gz" . compress . encode $ myvalue
More information about the Haskell-Cafe