将 ML 风格的模块添加到 Haskell 的主要理论困难是什么?

发布于 2024-11-01 21:50:13 字数 603 浏览 1 评论 0原文

众所周知,Haskell 风格的类型类和 ML 风格的模块提供了不同的机制来指定接口。它们的权力(可能)相当,但实际上每个都有自己的优点和缺点。

由于我在语言功能方面有点包容主义者,所以我的问题是:向 Haskell 添加 ML 风格模块的主要理论困难是什么?我对以下几方面的答案感兴趣:

  • 哪些现有类型系统功能与 ML 样式模块的交互效果不佳? (交互不良的一个例子是 GADT 和函数依赖关系,尽管fundeps 在技术上等同于关联类型!)

  • 为了编译 ML 风格的模块,编译器端必须放弃哪些东西?

  • ML 样式模块如何与类型推断交互?

相关阅读:

It is well known that Haskell-style typeclasses and ML-style modules offer different mechanisms for specifying interfaces. They are (possibly) equivalent in power, but in practice each has their own benefits and drawbacks.

Since I'm a bit of an inclusionist when it comes to language features, my question is this: What are the primary theoretical difficulties with adding ML-style modules to Haskell? I'm interested in answers along the following lines:

  • What existing type system features interact poorly with ML-style modules? (An example of poor interaction is GADT and functional dependencies, even though fundeps are technically equivalent to associated types!)

  • What things have to be given up on the compiler end in order to compile ML-style modules?

  • How do ML style modules interact with type inference?

Related reading:

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

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

发布评论

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

评论(3

赠佳期 2024-11-08 21:50:13

进行比较的主要地方是,

  • ML 模块和 Haskell类型类:建设性比较。 Stefan Wehr 和 Manuel MT Chakravarty。第六届亚洲编程语言和系统研讨会论文集 - APLAS 2008,Springer-Verlag,LNCS,2008 年。

  • 模块化类型类。德里克·德雷尔、罗伯特·哈珀和曼努埃尔·MT·查克拉瓦蒂。第 34 届年度 ACM SIGPLAN - SIGACT 编程语言原理研讨会论文集,ACM Press,2007 年。

  • Haskell、Mark Shields 和 Simon Peyton Jones 的一流模块。提交给第九届面向对象语言基础国际会议 (FOOL 9),俄勒冈州波特兰。 20 页。 2001 年 10 月。

我实际上并没有意识到任何理论问题——至少,已经提出了具体的建议(并在原型中实现了)——Shields 和 PJ 的论文有很多细节。然而,实施负担并非微不足道。

The main place to do the comparison is,

  • ML Modules and Haskell Type Classes: A Constructive Comparison. Stefan Wehr and Manuel M.T. Chakravarty. In Proceedings of The Sixth ASIAN Symposium on Programming Languages and Systems - APLAS 2008, Springer-Verlag, LNCS, 2008.

  • Modular Type Classes. Derek Dreyer, Robert Harper, and Manuel M. T. Chakravarty. In Proceedings of The 34th Annual ACM SIGPLAN - SIGACT Symposium on Principles of Programming Languages, ACM Press, 2007.

  • First class modules for Haskell, Mark Shields and Simon Peyton Jones. Submitted to the Ninth International Conference on Foundations of Object-Oriented Languages (FOOL 9), Portland, Oregon. 20 pages. Oct 2001.

I'm not actually aware of any theoretical issues -- at least, concrete proposals have been made (and implemented in prototypes) -- the Shields and PJ paper have a lot of the details. The implementation burden however, is non-trivial.

黄昏下泛黄的笔记 2024-11-08 21:50:13

我不认为有什么大的理论问题。您必须决定是否使用应用函子。 Applicative 可能更多的是 Haskell 风格。
但我认为任何向 Haskell 添加 ML 风格模块的尝试都将是怪诞的,因为模块和类之间存在重叠;很多事情都会有两种方法。

I don't think there's any big theoretical problems. You'd have to make a decision about applicative functors or not. Applicative is probably more in the Haskell style.
But I think any attempt at adding ML style modules to Haskell will be grotesque because the overlap between modules and classes; there will be two ways of doing many things.

尾戒 2024-11-08 21:50:13

Simon PJ has argued that ML style modules have a poor power/cost ratio, that they are hard to implement. See SPJ's slides from POPL 2003 (towards the end). He also calls for a design which has a better power/cost ration but I'm unaware of any such proposal.

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