OCaml 封装模块有哪些好的用途?

发布于 2024-09-12 04:49:37 字数 531 浏览 2 评论 0原文

最近的 OCaml 3.12 引入了一流打包模块的功能 :

一流的软件包模块。

  • 新的类型表达式,用于打包模块:(module PT)
  • 新的表达式,将模块打包为一流值:(module MODEXPR : PT)
  • 新型模块表达式,将一流值解包为模块:(val EXPR : PT)
  • PT 是 SS 形式的封装类型,其中类型 t1 = ... 和 ... 以及类型 tn = ... (S 指的是模块类型)。

在哪里可以找到使用此功能的激励性示例或论文?

The recent OCaml 3.12 introduces a feature of first-class packaged modules:

First-class packages modules.

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寒江雪… 2024-09-19 04:49:37

我相信典型的激励示例之一是根据仅在运行时可用的信息在实现相同签名的不同结构之间进行选择。

例如,在哈希表和平衡二叉树之间进行选择作为 Map 的实现。

有一些信息: https://forge.ocamlcore .org/docman/view.php/77/112/leroy-cug2010.pdf

我相信 OCaml 设计受到 Claudio Russo 对 SML 的类似扩展的影响 - 请参阅“标准 ML 的一流结构” http://citeseerx. ist.psu.edu/viewdoc/download?doi=10.1.1.34.8754&rep=rep1&type=pdf

I believe one of the canonical motivating examples is choosing between different structures implementing the same signature at based on information only available at runtime.

E.g., choosing between a hashtable and a balanced binary tree as an implementation of a Map.

There's some info at: https://forge.ocamlcore.org/docman/view.php/77/112/leroy-cug2010.pdf

I believe the OCaml design was influenced by a similar extension for SML by Claudio Russo - see e.g. "First-Class Structures for Standard ML" http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.34.8754&rep=rep1&type=pdf

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文