arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1202.2920cs.PL
收藏

数据类型泛型程序设计方法的形式化比较

A Formal Comparison of Approaches to Datatype-Generic Programming

José Pedro Magalhães, Andres Löh

摘要:

数据类型泛型编程通过使函数在不同类型之间统一操作来提高程序抽象和重用。多年来,人们提出了许多泛型编程的方法,其中大多数是针对Haskell的,但最近也有针对依赖类型语言(如Agda)的。不同的方法在表现力、易用性和实现技术方面各不相同。已经做了一些工作来非正式地比较不同的方法。然而,据我们所知,没有人试图正式证明不同方法之间的关系。因此,我们提出了一个正式的比较泛型编程库。我们将展示如何在Agda中正式化不同的方法,包括共归纳表示,然后建立定理,相互关联的方法。我们提供了一种方法包含在另一种方法中的建设性证明,可用于方法之间的转换,有助于减少不同库之间的代码重复。我们的形式化也有助于提供一个清晰的图片的潜力,每种方法,特别是在有关不同的通用视图和它们的表达。

英文摘要:

Datatype-generic programming increases program abstraction and reuse by making functions operate uniformly across different types. Many approaches to generic programming have been proposed over the years, most of them for Haskell, but recently also for dependently typed languages such as Agda. Different approaches vary in expressiveness, ease of use, and implementation techniques. Some work has been done in comparing the different approaches informally. However, to our knowledge there have been no attempts to formally prove relations between different approaches. We thus present a formal comparison of generic programming libraries. We show how to formalise different approaches in Agda, including a coinductive representation, and then establish theorems that relate the approaches to each other. We provide constructive proofs of inclusion of one approach in another that can be used to convert between approaches, helping to reduce code duplication across different libraries. Our formalisation also helps in providing a clear picture of the potential of each approach, especially in relating different generic views and their expressiveness.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑