Skip to content

[OxCaml] Parameterized libraries: library instantiation #12088

@maiste

Description

@maiste

This issue tracks the work related to the instantiation of the parameterized libraries. It requires #12084, #12085 and, #12086 to be completed before it can be merged. It is the last piece of the 4 main PRs related to the Parameterized libraries.

Finally, libraries and executables should be able to depend on the instantiation of a parameterized library applied to parameters:

(library ; and executable, tests, etc
  ...
  (libraries
	(mylib p_impl1) 
; ocamlc -instantiate lib.cmo p_impl.cmo q_impl.cmo -o lib-P_impl-Q_impl.cmo
	(lib p_impl2 :as newname))
  ...)

This adds a step in the compilation to bind the parameterized library to its parameters, with a compiler call with the flag -instantiate … p_impl.cm. If :as newname is specified, then the instantiated library should be available under Newname; otherwise, it defaults to the parameterized library name Lib. To access the instantiated libraries, dune should produce a module newname.ml with the code:

include Lib(P_intf)(P_impl) [@jane.non_erasable.instances]

Dune should check that the instantiated dependencies have access to all their parameters (or that any missing one is listed in the (parameters) of the defined library), and produce an error otherwise. For executables and tests, all parameters should be provided.

Metadata

Metadata

Assignees

Labels

oxcamlRelated to the support to OxCaml functionnalities

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions