Affiliation:
1. Chalmers University of Technology and Göteborg University
Abstract
This paper introduces a pattern for almost compositional functions over recursive data types, and over families of mutually recursive data types. Here "almost compositional" means that for a number of the constructors in the type(s), the result of the function depends only on the constructor and the results of calling the function on the constructor's arguments. The pattern consists of a generic part constructed once for each data type or family of data types, and a task-specific part. The generic part contains the code for the predictable compositional cases, leaving the interesting work to the task-specific part. Examples of the pattern implemented in dependent type theory with inductive families, in Haskell with generalized algebraic data types and rank-2 polymorphism, and in Java using a variant of the Visitor design pattern are given. The relationship to the "Scrap Your Boilerplate" approach to generic programming, and to general tree types in dependent type theory are also investigated.
Publisher
Association for Computing Machinery (ACM)
Subject
Computer Graphics and Computer-Aided Design,Software
Reference21 articles.
1. BRINGERT B. The Transfer programming language. http://www.cs.chalmers.se/.~aarne/GF/doc/transfer.html. BRINGERT B. The Transfer programming language. http://www.cs.chalmers.se/.~aarne/GF/doc/transfer.html.
2. COQUAND C. The Agda homepage. http://www.cs.chalmers.se/~catarina/agda/. COQUAND C. The Agda homepage. http://www.cs.chalmers.se/~catarina/agda/.
Cited by
2 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Generic Programming in OCaml;Electronic Proceedings in Theoretical Computer Science;2018-12-31
2. Modular reifiable matching: a list-of-functors approach to two-level types;Proceedings of the 2015 ACM SIGPLAN Symposium on Haskell;2015-08-30