MantisBT - OCaml
View Issue Details
0005615OCamlstandard librarypublic2012-05-15 05:472012-05-15 16:26
0005615: Being able to (un)marshal to/from compressed files

It would be nice to support reading/writing
from/to compressed files.
The compression level should be an optional
user-supplied parameter.

No tags attached.
Issue History
2012-05-15 05:47berengerNew Issue
2012-05-15 15:59frischNote Added: 0007435
2012-05-15 15:59frischStatusnew => resolved
2012-05-15 15:59frischResolutionopen => suspended
2012-05-15 15:59frischAssigned To => frisch
2012-05-15 16:26xleroyNote Added: 0007437
2017-02-23 16:43doligezCategoryOCaml standard library => standard library

2012-05-15 15:59   
I don't see that happening in the standard distribution: this would either introduce a dependency to an external compression library or require to integrate one in OCaml's source tree.

Ideally, the marshaler/demarshaler should have an API to allow plugging custom input/output streams. Unfortunately, given the current implementation, it is difficult to call back into OCaml code during marshaling/demarshaling. This could be done at the C level in order to allow plugging an external compression library.

I'm suspending this ticket for now. If someone from the community is willing to work on it, I suggest contacting the developers first to see if there is a chance of having such a patch accepted.
2012-05-15 16:26   
To complement A. Frisch's reply: you can always marshal to/from strings, using Marshal.to_string and Marshal.from_string, then combine this with whatever compression method you'd like. (The Camlzip library,, [^] could be a good candidate for the compression part.)

The OCaml Batteries library ( [^]) has support for custom input/output streams, but not yet for compressed streams, if I understand correctly. It could still be worth asking on the OCaml Batteries mailing-list, though.