ocaml wish

Let’s say I have a function with some optional arguments and some mandatory ones:

let f ?a ?b c = ...

And let’s say the b argument should only be used inside this module. It would be nice to be able to just put

val f : ?a : 'a -> c -> 'b -> 'c

in my mli, to restrict the outside world from seeing the optional b argument. It seems that this might be tricky to implement from the standpoint of separate compilation.

Right now the best workaround I can come up with is to make a separate function to export to the outside world which simply calls the internal one appropriately.

Leave a Reply

Your email address will not be published. Required fields are marked *