Does `module%private` exist?


#1

I just found out this syntax:

let%private myValue = 1;

(see: https://reasonml.org/blog/bucklescript-release-7-2)

Does such a syntax exist for the modules ?
For example:

module%private MyPrivateModule = {
   type t = string;
   let name = "joseph maarek";
   // ...
};

It would be very convenient for aliasing module without export it.

module%private Image = React_Component_Image;

// ...
<Image id=123 />

#2

it exists in OCaml 4.08: https://github.com/ocaml/ocaml/pull/2122

If and when BuckleScript upgrades to (or above) that version, it will automatically get it.

EDIT; on second thought, this is not actually what you asked for, sorry. I think it only works in interface files.


#3

For ml file, you can use open struct ... end, the syntax in mli file is more restricted and amount essentially to private abbreviations.


#4

I logged a ticket about this at the time:

tl;dr is it’s not planned in the short term, but might happen eventually.


#5

yes it exisits:-
A private-module-fragment ends the portion of the module interface unit that can affect the behavior of other translation units. A private-module-fragment allows a module to be represented as a single translation unit without making all of the contents of the module reachable to importers. The presence of a private-module-fragment affects:
the point by which the definition of an exported inline function is required ([dcl.inline])
the point by which the definition of an exported function with a placeholder return type is required ([dcl.spec.auto])
whether a declaration is required not to be an exposure ([basic.link]),
where definitions for inline functions and templates must appear ([basic.def.odr], [dcl.inline], [temp.pre]),
the instantiation contexts of templates instantiated before it ([module.context]), and
the rachability of declarations within it ([module.reach]).


#6

It is a copy/past of section of this link http://www.eelis.net/c++draft/module#private.frag

This link is about C++ module, not ocaml, reasonml, rescript / bucklescript.


#7

Is it some kind of chatbot?