But since camlzip does not have an input_value function, it seems I must set up a buffer to decompress the data, then use Marshal to obtain input data from the decompressed buffer. But if I use Marshal.from_string to read the decompressed buffer, then I need to keep track of its position (which is not returned by Marshal.from_string), and check whether the buffer is nearly empty, so that I may need to re-read from the compressed in_channel, etc, etc. Did I miss the right function again? It seems that Netgzip would require some similar amount of effort, from what I'm seeing (I see no "channel -> 'a" functions in the API). Thanks for the serialization tips, though I don't care much about the safety, I have strong assumptions about the how the data will be produced and consumed. On Mon, Feb 2, 2015 at 5:48 PM, Drup wrote: > input/output_value are using Marshal under the hood, so it's going to be > the same. > > However, be aware that marshall (and the _value functions) are quite > unsafe. If you have an error in the data (or your change the representation > in OCaml), you will have ... surprising errors (including segfaults). > > There are plenty of safer solutions for serialization (deriving, sexp, > yojson, to name a few). > > Le 02/02/2015 17:05, Dhek Uir a écrit : > > > > On Mon, Feb 2, 2015 at 4:43 PM, Jacques-Henri Jourdan < > jacques-henri.jourdan@inria.fr> wrote: > >> Le 02/02/2015 16:39, Dhek Uir a écrit : >> > I'm looking for a compression library such as camlzip to read/write >> > compressed files (any lossless compression algorithm is fine), but >> > having a function similar to Pervasives.output_value, which does not >> > seem to be available in camlzip (and I do not see how I could easily >> > implement it). >> > >> > Would it be simple to modify camlzip to add this function? I believe >> > that if this were the case, then it would already have been done, but >> > I might be wrong. >> > >> > Otherwise, is there another OCaml library with an API very similar to >> > Pervasives'? I'd prefer a lightweight solution (avoiding Core and >> > Batteries) if possible. >> >> Can't you do Marshal.to_string, and then use Camlzip on the generated >> string ? >> >> > Indeed, I can. I believe the hard part is actually the input_value > operation. > But I haven't looked enough into Marshal, maybe my solution can be found > there. > > >