将 ML 风格的模块添加到 Haskell 的主要理论困难是什么?
众所周知,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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
进行比较的主要地方是,
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.
我不认为有什么大的理论问题。您必须决定是否使用应用函子。 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.
Simon PJ 认为 ML 风格的模块的功耗/成本比很差,因此很难实现。请参阅 SPJ 来自 POPL 2003 的幻灯片< /a>(接近尾声)。他还呼吁一种具有更好的功率/成本比的设计,但我不知道有任何这样的建议。
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.