Haskell 的多态性风格是什么?
对于 Haskell 的类型类,它几乎似乎支持临时多态性,但它的函数声明似乎是参数多态性。我是否混淆了对不同事物的理解?
With Haskell's type classes it almost seems that it enables ad hoc polymorphism, but its functions declarations seem parametric polymorphism. Am I mixing my understanding of different things?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实上,Haskell 支持(更高级别的)参数多态性和临时(或有界)多态性。 Haskell 中的参数多态性是通过其 Hindley-Milner/System F 类型系统支持的。通过类型类支持临时多态性。
有关类型类和临时多态性的起源,请参阅 Wadler 的论文:
有关参数多态性和临时多态性之间区别的起源,您可以挖掘 Strachey 的论文,
Indeed, Haskell supports both (higher rank) parametric polymorphism, and ad hoc (or bounded) polymorphism. Parametric polymorphism in Haskell is supported via its Hindley-Milner/System F type system. Ad hoc polymorphism is supported via type classes.
For the origin of type classes and ad hoc polymorphism, see Wadler's papers:
For the origin of the distinction between parametric and ad hoc polymorphism, you can dig up Strachey's papers,