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

查看:171
本文介绍了什么是Haskell的多态的风格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Haskell的类型类几乎可以使特殊的多态性成为可能,但是它的函数声明似乎是参数多态性。我在混合我对不同事物的理解吗?

解决方案

的确,Haskell同时支持(更高级别)参数多态和ad hoc(或 bounded )多态性。 Haskell中的参数多态性是通过其Hindley-Milner / 系统F 类型系统来支持的。特别的多态性是通过类型类来支持的。



对于类型类和特别多态的起源,请参阅Wadler的论文:



关于区分参数化和ad hoc多态性,您可以挖掘Strachey的论文, b
$ b


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?

解决方案

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,

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

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