OCaml batteries, now with GZip-ed channels
This week-end I've spent some time to kick-start my hacking onto OCaml Batteries Included (yes, it deserves a proper website).
Last time I
wrote about it was with my package maintainer hat on. In the
meantime I've got trapped^W
involved with upstream
development as well, after having been so fool to propose
integration with
Batteries' I/O channels of compression/decompression
libraries.
Well, here are the first tiny teeny results:
# open Batteries.System;;
# let i = File.open_in "/tmp/fstab.gz";;
val i : InnerIO.input = <abstr>
# let i2 = GZip.uncompress i;;
val i2 : InnerIO.input = <abstr>
# IO.read_line i2;;
- : string = "# /etc/fstab: static file system information."
# IO.read_line i2;;
- : string = "#"
# (* same goes for output of course *)
i.e., no matter how you created an I/O channel (and with
Batteries you can create it out of a lot of entities), you
can apply a gzip
compress/decompress filter.
The underlying library is Camlzip, which also sets a precedent on how to integrate external libraries into Batteries properly.
The code is not released yet (hey, Batteries is still alpha!), but is available from the Git repo, (zack/compress branch).
Next milestone: bzip2
... of course with the same
interface, so that changing (de)compressor will be as easy as
s/GZip/BZip2/g
in the code above. tar
and
zip
will come next (but with different interfaces, as
old *nix jokes tell us, compressing and archiving are different
tasks).