The closest thing to a full-fledged OCaml API doc site is http://docs.mirage.io/
Unfortunately, it’s not very searchable. For example, if you go to the above page looking for the
Core.Std.Out_channel.create function, you’ll be shown a list of OPAM package names and you’ll have to know that
core is the package that contains this function.
Anyway, once you go into core looking for the function, you can, with a little luck, navigate through a series of indirect modules and eventually come to http://docs.mirage.io/stdio/Stdio/Out_channel/index.html#val-create
There you can see that the type of the function is defined slightly above the function itself, http://docs.mirage.io/stdio/Stdio/Out_channel/index.html#type-with_create_args . You might wonder why they did that.
Interestingly, if you search for that type,
with_create_args, you’ll see the function
with_file, which seems to take a file handler function and creation arguments, and lets you perform some operation. I’m not sure because it’s not documented, but from the type of the function, it might actually be opening the file, doing an operation on it, and automatically closing it–in other words, doing the same job as
You can try it out:
let create_number_file filename str = Out_channel.with_file
~f:(fun outc -> fprintf outc "str = %s\n" str)
And if it works for you and you’re feeling helpful, you could send a PR documenting this function so the next person can get it a little quicker