ocamlbuild icon indicating copy to clipboard operation
ocamlbuild copied to clipboard

main API should not export utility modules

Open agarwal opened this issue 10 years ago • 3 comments

The main API defines modules like List and String. This is not a high priority issue, but I feel this is inappropriate and should be removed. The particular (easy to workaround) problem I had is:

module List = struct
  include List
  include ListLabels
end
open Ocamlbuild_plugin
(* Oops, my List module above is shadowed. *)

agarwal avatar Dec 22 '15 20:12 agarwal

This is a fair point. We should move these modules to an Library submodule of the PLUGIN interface, so that people previously using these functions can still access them easily.

Another nice thing to do would be to expose modules with only the new functions added by ocamlbuild, in for example Library.ListExtension (so Library.List would just be struct include List include ListExtension end), so that people can open or include ListExtension to add to their own modules if they find its features useful.

gasche avatar Dec 24 '15 08:12 gasche

My solution to this is:

  • All modules are namespace'd by using a prefix, so here module names would be OCamlbuild_tags, OCamlbuild_list, etc.
  • Define a Std module (or name it whatever you want). This is the main API entry point. Within this module, you export the modules that are the real API.

Now, all modules are accessible if somebody really wants them, but it's clear that some aren't really what the project provides.

agarwal avatar Dec 24 '15 18:12 agarwal

+1 for @agarwal's suggestion

rgrinberg avatar Dec 24 '15 18:12 rgrinberg