[RFC] Add hidden directory (proposed in RFC 31)#11989
[RFC] Add hidden directory (proposed in RFC 31)#11989bobot wants to merge 2 commits intoocaml:trunkfrom
Conversation
but consider it like -I for now
|
I worked a bit with @bobot on this prototype implementation of the RFC (the There is a testsuite by François that checks that the various "obvious" cases work as intended. This is very reassuring. The general idea of the implementation is as follows:
Subtlety: which lookups to check?I thought at first that we should instrument all (* A.ml : imported hidden *)
type t = Toto
(* B.mli: imported visible *)
val f : A.t -> unit
(* C.ml: being type-checked *)
let () = B.f TotoIt depends on the specification that we want for hidden compilation units:
Subtlety:
|
|
I don't love the idea of fix #9991 a different way. The advantage of the current approach is that it makes sure that the existence or not of unused immaterial cmi files can't possibly affect the result of compilation. Fixing one particular case with hash-consing might not have that property if there turn out to be other ways it can affect things. I think there is a much easier solution here:
Then there is no need to record which modules are hidden or not. It is just that |
I forgot that we only put the material ones in the environment now, so that's not quite right. It should be:
|
|
Yes, we tried your earlier suggestion of "When looking up using a lookup_foo function you only use modules in the environment.', and it did not work. We should try your revised suggestion. If I understand correctly, we need to send the "are we accessing from |
|
Yeah, that sounds right. |
|
For conciseness, I'll use @gasche was saying it's debatable whether this should be a type error or not: type X.t = C
val I.f : X.t -> unit
let () = I.f CI think this should be accepted, for two reasons. First, even if I'll also mention that the client code can manipulate module X = struct type t = C end
module I = struct let f (_ : X.t) = () end
(* no mention of X from here *)
module type T = sig type t end
let type_of_arg (type a) (_ : a -> unit) : (module T with type t = a) =
(module struct type t = a end)
module Type_of_f_arg = (val type_of_arg I.f)
let _ : Type_of_f_arg.t = CSecond, it's probably useful to think about the purpose of this change: we want to force the client code to state it uses |
|
Thank you @ccasin for taking the ball I dropped. |
It is a POC for RFC 31:
- In the initial environment the hidden modules are added as
Mod_persistent { hidden = true }instead ofMod_persistent.- In the
lookup_ident_module, those modules raise an error. I think this function is used only for the user provided identifiers, since modules that are not found raises an error which is not the case if it is a name that comes from a signature.-Iand-Hare gathered in the same list of path in order to handle the priorities in a consistent way. That change the type ofClflags.include_dirs. The first commit propages this change.-Hdoes not work yet with-no-alias-depsbecause in this case initial modules are not always added to the environment. So I will change that separately with different fix for Fix reproducibility for-no-alias-deps#9991.