参数组合数据类型
Parametric Compositional Data Types
摘要:
在以前的工作中,我们已经说明了组合数据类型(CDTs)为实现语言和处理抽象语法树(AST)提供的好处。基于Swierstra的数据类型la carte,CDT被实现为一个Haskell库,该库以模块化和可扩展的方式定义递归数据类型和函数。虽然CDTs提供了一个强大的工具来分析和操纵AST,他们缺乏一个方便的表示变量绑定。在本文中,我们弥补这一不足,结合框架的CDTs与Chlipala的参数高阶抽象语法(PHEAS)。我们展示了如何从函子到反函子的概括使我们能够捕获PHOAS,同时仍然保持CDTs的原始实现的功能,特别是其模块化。与以前的方法不同,我们避免了所谓的外来术语,而不诉诸抽象类型:当我们想要在CDT上执行检查递归计算的CDT的转换时,这是至关重要的,例如常数折叠。
英文摘要:
In previous work we have illustrated the benefits that compositional data types (CDTs) offer for implementing languages and in general for dealing with abstract syntax trees (ASTs). Based on Swierstra's data types á la carte, CDTs are implemented as a Haskell library that enables the definition of recursive data types and functions on them in a modular and extendable fashion. Although CDTs provide a powerful tool for analysing and manipulating ASTs, they lack a convenient representation of variable binders. In this paper we remedy this deficiency by combining the framework of CDTs with Chlipala's parametric higher-order abstract syntax (PHOAS). We show how a generalisation from functors to difunctors enables us to capture PHOAS while still maintaining the features of the original implementation of CDTs, in particular its modularity. Unlike previous approaches, we avoid so-called exotic terms without resorting to abstract types: this is crucial when we want to perform transformations on CDTs that inspect the recursively computed CDTs, e.g. constant folding.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。