简体   繁体   English

什么是Haskell的多态性风格?

[英]What is Haskell's style of polymorphism?

With Haskell's type classes it almost seems that it enables ad hoc polymorphism, but its functions declarations seem parametric polymorphism. 使用Haskell的类型类似乎它几乎可以实现ad hoc多态,但它的函数声明似乎是参数多态。 Am I mixing my understanding of different things? 我混合了对不同事物的理解吗?

Indeed, Haskell supports both (higher rank) parametric polymorphism, and ad hoc (or bounded ) polymorphism. 实际上,Haskell支持(更高级别)参数多态性和ad hoc(或有界 )多态性。 Parametric polymorphism in Haskell is supported via its Hindley-Milner/ System F type system. Haskell中的参数多态通过其Hindley-Milner / System F类型系统得到支持。 Ad hoc polymorphism is supported via type classes. 通过类型类支持Ad hoc多态。

For the origin of type classes and ad hoc polymorphism, see Wadler's papers: 对于类类和ad hoc多态的起源,请参阅Wadler的论文:

For the origin of the distinction between parametric and ad hoc polymorphism, you can dig up Strachey's papers, 对于参数和ad hoc多态的区别的起源,你可以挖掘Strachey的论文,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM