Haskell 的多态风格是什么? [英] What is Haskell's style of polymorphism?

查看:36
本文介绍了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?

推荐答案

确实,Haskell 支持(更高级别的)参数多态性和 ad hoc(或 有界)多态性.Haskell 中的参数多态性通过其 Hindley-Milner/System F 类型系统得到支持.通过类型类支持临时多态性.

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.

关于类型类和即席多态性的起源,请参阅 Wadler 的论文:

For the origin of type classes and ad hoc polymorphism, see Wadler's papers:

  • 如何减少临时多态性,菲利普·瓦德勒和斯蒂芬·布洛特.第 16 届编程语言原理研讨会,ACM 出版社,德克萨斯州奥斯汀,1989 年 1 月.
  • 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.

关于parametric多态性和ad hoc多态性区别的由来,可以去挖Strachey的论文,

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

这篇关于Haskell 的多态风格是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆