System F-omega with Equirecursive Types for Datatype-Generic Programming

被引:6
|
作者
Cai, Yufei [1 ]
Giarrusso, Paolo G. [1 ]
Ostermann, Klaus [1 ]
机构
[1] Univ Tubingen, Tubingen, Germany
关键词
Datatype-generic programming; equirecursive types; functors;
D O I
10.1145/2914770.2837660
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Traversing an algebraic datatype by hand requires boilerplate code which duplicates the structure of the datatype. Datatype-generic programming (DGP) aims to eliminate such boilerplate code by decomposing algebraic datatypes into type constructor applications from which generic traversals can be synthesized. However, different traversals require different decompositions, which yield isomorphic but unequal types. This hinders the interoperability of different DGP techniques. In this paper, we propose F-omega(mu), an extension of the higher-order polymorphic lambda calculus F-omega with records, variants, and equirecursive types. We prove the soundness of the type system, and show that type checking for first-order recursive types is decidable with a practical type checking algorithm. In our soundness proof we define type equality by interpreting types as infinitary lambda-terms (in particular, Berarducci-trees). To decide type equality we beta-normalize types, and then use an extension of equivalence checking for usual equirecursive types. Thanks to equirecursive types, new decompositions for a datatype can be added modularly and still inter-operate with each other, allowing multiple DGP techniques to work together. We sketch how generic traversals can be synthesized, and apply these components to some examples. Since the set of datatype decomposition becomes extensible, System F-omega(mu) enables using DGP techniques incrementally, instead of planning for them up-front or doing invasive refactoring.
引用
收藏
页码:30 / 43
页数:14
相关论文
共 5 条
  • [1] Datatype-generic programming
    Gibbons, Jeremy
    [J]. DATATYPE-GENERIC PROGRAMMING, 2007, 4719 : 1 - +
  • [2] Arity-Generic Datatype-Generic Programming
    Weirich, Stephanie
    Casinghino, Chris
    [J]. PLPV'10: PROCEEDINGS OF THE 2010 ACM SIGPLAN WORKSHOP ON PROGRAMMING LANGUAGES MEETS PROGRAM VERIFICATION, 2010, : 15 - 26
  • [3] Datatype-Generic Programming Meets Elaborator Reflection
    Ko, Hsiang-Shang
    Chen, Liang-Ting
    Lin, Tzu-Chi
    [J]. PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL, 2022, 6 (ICFP):
  • [4] A Formal Comparison of Approaches to Datatype-Generic Programming
    Magalhaes, Jose Pedro
    Loeh, Andres
    [J]. ELECTRONIC PROCEEDINGS IN THEORETICAL COMPUTER SCIENCE, 2012, (76): : 50 - 67
  • [5] A NON-TYPABILITY RESULT IN THE SYSTEM F-OMEGA
    ROZIERE, P
    [J]. COMPTES RENDUS DE L ACADEMIE DES SCIENCES SERIE I-MATHEMATIQUE, 1989, 309 (13): : 799 - 802