From: Nicolas C. <nca...@mo...> - 2006-07-30 13:43:13
|
> A recent project required me to parse gzipped XML files using Xml-Light. > The most convenient way to access the gzipped files was using Extlib's > Unzip.inflate on an IO.input stream. However, since Xml-Light does not > support IO or the standard OO file interface (it only supports input > from files, Pervasives streams, strings, and lexbufs), it was necessary > to define a wrapper function: > > let lexbuf_of_input i = > Lexing.from_function > (fun s n -> > try > IO.input i s 0 n > with IO.No_more_input -> > 0);; > > I just wonder whether it might be worth adding a couple of conversion > functions along these lines to the IO module, since I can imagine them > being generally useful? The code is trivial, but one of the things I > value Extlib for is that it reduces the need for boilerplate like this. Hi Peter, The only problem is that this would create an IO -> Lexing dependency. OCaml performs linkage on a per-module basis so not sure it's nice to add such an overweight for a single simple function. Nicolas |