I have a function of type in_channel -> out_channel -> unit
which will output something to an out_channel
. Now I'd like to get its output as a string. Creating temporary files to write and read it back seems ugly, so how can I do that? Is there any other methods to create out_channel
besides Pervasives.open_out
family?
Actually, this function implemented a repl. What I really need is to test it programmatically, so I'd like to first wrap it to a function of type string -> string
. For creating the in_channel
, it seems I can use Scanf.Scanning.from_string
, but I don't know how to create the out_channel
parameter.