ANNOUNCE: Codec.Compression.GZip & .BZip

I'm pleased to announce two new packages: zlib and bzlib which provide functions for compression and decompression in the gzip and bzip2 formats: Both provide pure functions on streams of data represented by lazy ByteStrings: compress, decompress :: ByteString -> ByteString This makes it easy to use either in memory or with disk or network IO. For example a simple gzip compression program is just:
import qualified Data.ByteString.Lazy as ByteString import qualified Codec.Compression.GZip as GZip
main = ByteString.interact GZip.compress
Or you could lazily read in and decompress @.gz@ file using:
content <- fmap GZip.decompress (readFile file)
The code is available via darcs: darcs get http://haskell.org/~duncan/zlib darcs get http://haskell.org/~duncan/bzlib (Note that if you are using GHC-6.5 then you'll need to edit the .cabal file to remove the dependency on fps, since ByteStrings are provided in the base package in GHC-6.5.) There is API documentation too: http://haskell.org/~duncan/zlib/docs http://haskell.org/~duncan/bzlib/docs Both packages are bindings to the corresponding C libs, so they depend on those C libraries. Fortunately both zlib and bzlib2 are available on every OS. It also means that the compression speed is as you would expect since it's the C lib that is doing all the work. I'm very happy to get feedback on the API, the documentation or of course any bug reports. Duncan

Hello Duncan, Thursday, September 21, 2006, 12:11:28 PM, you wrote:
I'm pleased to announce two new packages: zlib and bzlib which provide functions for compression and decompression in the gzip and bzip2 formats:
that's great! i even think that these libraries should go into ghc's extra-libs package
Both provide pure functions on streams of data represented by lazy ByteStrings:
compress, decompress :: ByteString -> ByteString
i'd plans to add compression support to my Streams library and your work will definitely make simpler my own about API - while it's great for simple usage, it's not enough universal. i think that the most universal one is using callbacks to read and write memory buffers, as implemented in my own compression library: http://haskell.org/haskellwiki/Library/Compression -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

On Thu, 2006-09-21 at 14:20 +0400, Bulat Ziganshin wrote:
Hello Duncan,
Thursday, September 21, 2006, 12:11:28 PM, you wrote:
I'm pleased to announce two new packages: zlib and bzlib which provide functions for compression and decompression in the gzip and bzip2 formats:
that's great! i even think that these libraries should go into ghc's extra-libs package
Both provide pure functions on streams of data represented by lazy ByteStrings:
compress, decompress :: ByteString -> ByteString
i'd plans to add compression support to my Streams library and your work will definitely make simpler my own
about API - while it's great for simple usage, it's not enough universal. i think that the most universal one is using callbacks to read and write memory buffers, as implemented in my own compression library: http://haskell.org/haskellwiki/Library/Compression
Is the code available? I don't see any link to it. Can you think of any examples where one covers more cases than the other? Both can handle the in memory or disk/network cases. Both provide the full range of compression algorithm tuning parameters.
From what it looks like from the examples on that page, you always have to work in the IO monad, so it's less 'universal' in that sense. Can you (de)compress lazily with your system?
Duncan
participants (2)
-
Bulat Ziganshin
-
Duncan Coutts