泛型和约束多态与子类型 [英] Generics and Constrained Polymorphism versus Subtyping

查看:113
本文介绍了泛型和约束多态与子类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此 PDF演示文稿关于Haskell类型类,幻灯片#54有这样一个问题:


打开问题 p>

在使用泛型和
约束多态的语言中,是否也需要
子类型?

我的问题是:


  1. 泛型和约束多态如何使子类型不必要?


解决方案

Oleg Kiselyov和RalfLämmel的Haskell忽略的对象系统为Haskell提出了一个库,它使用Haskell的现有fe实现了一个对象系统

本文的引言部分摘录(重点介绍):

< blockquote>

对这个主题的兴趣并不完全限于Haskell的研究人员和从业者,因为存在一个根本性的和未解决的问题 - 本文论述的一个问题:

        类型有界和子类型多态之间的关系是什么? b

在这个研究环境中,我们具体(并且强调)将自己限制在现有的Haskell语言(Haskell 98和必要时的常见扩展),
,即没有新的Haskell扩展将被提出。 正如我们将证实的那样,这个
限制是适当的,因为它允许我们为上述问题提供有意义的重要答案。



In this PDF presentation on Haskell Type Classes, slide #54 has this question:

Open Question:

In a language with generics and constrained polymorphism, do you need subtyping too?

My questions are:

  1. How do generics and constrained polymorphism make subtyping unnecessary?

  2. If generics and constrained polymorphism make subtyping unnecessary, why does Scala have subtyping?

解决方案

Oleg Kiselyov and Ralf Lämmel's "Haskell's overlooked object system" proposes a library for Haskell that implements an object system using Haskell's existing features, including type classes.

An excerpt from the "introduction" section of the paper (emphasis mine):

The interest in this topic is not at all restricted to Haskell researchers and practitioners since there is a fundamental and unsettled question — a question that is addressed in the present paper:

       What is the relation between type-class-bounded and subtype polymorphism?

In this research context, we specifically (and emphatically) restrict ourselves to the existing Haskell language (Haskell 98 and common extensions where necessary), i.e., no new Haskell extensions are to be proposed. As we will substantiate, this restriction is adequate, as it allows us to deliver a meaningful and momentous answer to the aforementioned question.

这篇关于泛型和约束多态与子类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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