What is Haskell's style of polymorphism?

依然范特西╮ 提交于 2019-12-29 18:37:03

问题


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?


回答1:


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:

  • How to make ad-hoc polymorphism less ad hoc, Philip Wadler and Stephen Blott. 16'th Symposium on Principles of Programming Languages, ACM Press, Austin, Texas, January 1989.

For the origin of the distinction between parametric and ad hoc polymorphism, you can dig up Strachey's papers,

  • C. Strachey, Fundamental concepts in programming languages. Lecture notes for the International Summer School in Computer Programming, Copenhagen, August 1967


来源:https://stackoverflow.com/questions/5671303/what-is-haskells-style-of-polymorphism

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!