What are the good options for using OCAMl packages?

The latest OCaml 3.12 introduces the function of first-class packaged modules:

First Class Package Modules.

  • A new type of type expression for packaged modules: (module PT)
  • A new kind of expression to package a module as a first-class value: (module MODEXPR : PT) .
  • A new kind of module expression to unpack the value of the first class as a module: (val EXPR : PT) .
  • PT is a package type of form S or S with type t1 = ... and ... and type tn = ... ( S refers to the type of module).

Where can I find motivating examples or documents using this feature?

+6
ocaml
source share
1 answer

I believe that one of the canonical motivating examples is the choice between different structures that implement the same signature, based on information available only at runtime.

For example, choosing between a hash table and a balanced binary tree as a map implementation.

There is information at: https://forge.ocamlcore.org/docman/view.php/77/112/leroy-cug2010.pdf

I believe that the OCaml design was influenced by a similar extension for SML by Claudio Russo - see, for example, β€œFirst Class Structures for Standard ML” http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.34. 8754 & rep = rep1 & type = pdf

+5
source share

All Articles