4 ms·
OCaml has a typesystem in which modules are first-class citizens, just like functions. They have a clear separation between interface (they call it "signatures"
by vog 11y ago
OCaml has a typesystem in which modules are first-class citizens, just like functions. They have a clear separation between interface (they call it "signatures") and implementation. The compiler enforces that you can only write against the interface, making modules with the same interface really exchangeable. The modules are also parametrizable (they call such modules "functors").
http://caml.inria.fr/pub/docs/manual-ocaml/moduleexamples.html http://caml.inria.fr/pub/docs/manual-ocaml/moduleexamples.ht...
https://realworldocaml.org/v1/en/html/functors.html https://realworldocaml.org/v1/en/html/functors.html
https://realworldocaml.org/v1/en/html/first-class-modules.html https://realworldocaml.org/v1/en/html/first-class-modules.ht...
- tom_mellior 11y agoThat's all true, but it doesn't mean that OCaml has a "consistent API model", whatever that may mean. Unless "provide a fold and a map for all datatypes", which I guess is consistent across most APIs, is a "model".