This commit is contained in:
swrup 2025-11-11 02:07:51 +01:00
parent aa2ff7b2f0
commit 2f3113f55d
11742 changed files with 1223940 additions and 0 deletions

View file

@ -0,0 +1,7 @@
(executable
(name test)
(libraries foo_impl))
(alias
(name default)
(action (run ./test.exe)))

View file

@ -0,0 +1,3 @@
let run () =
Priv.run ();
print_endline "implementing bar"

View file

@ -0,0 +1,4 @@
(library
(name foo_impl)
(private_modules priv)
(implements foo))

View file

@ -0,0 +1 @@
let run () = print_endline "Private module Baz"

View file

@ -0,0 +1,25 @@
They can only introduce private modules:
$ dune build --debug-dependency-path
Private module Baz
implementing bar
Note the aliasing scheme for implementations differs form other libraries. In
particular, we use a longer prefix for private modules of implementations so
that they never collide with modules present in the virtual library.
$ cat _build/default/impl/foo__foo_impl__.ml-gen
(* generated by dune *)
(** @canonical Foo.Bar *)
module Bar = Foo__Bar
(** @canonical Foo.Priv *)
module Priv = Foo__foo_impl__Priv
Here we look at the raw artifacts for our implementation and verify it matches
the alias:
$ ls _build/default/impl/.foo_impl.objs/byte/*.cmi
_build/default/impl/.foo_impl.objs/byte/foo__Bar.cmi
_build/default/impl/.foo_impl.objs/byte/foo__foo_impl__.cmi
_build/default/impl/.foo_impl.objs/byte/foo__foo_impl__Priv.cmi

View file

@ -0,0 +1,3 @@
(library
(name foo)
(virtual_modules bar))