Boxes go bananas: Encoding higher-order abstract syntax with parametric polymorphism

被引:24
作者
Washburn, G [1 ]
Weirich, S [1 ]
机构
[1] Univ Penn, Dept Comp & Informat Sci, Philadelphia, PA 19104 USA
关键词
higher-order abstract syntax; modal type system; catamorphism; parametricity; parametric polymorphism;
D O I
10.1145/944746.944728
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Higher-order abstract syntax is a simple technique for implementing languages with functional programming. Object variables and binders are implemented by variables and binders in the host language. By using this technique, one can avoid implementing common and tricky routines dealing with variables, such as capture-avoiding substitution. However, despite the advantages this technique provides, it is not commonly used because it is difficult to write sound elimination forms (such as folds or catamorphisms) for higher-order abstract syntax. To fold over such a datatype, one must either simultaneously define an inverse operation (which may not exist) or show that all functions embedded in the datatype are parametric. In this paper, we show how first-class polymorphism can be used to guarantee the parametricity of functions embedded in higher-order abstract syntax. With this restriction, we implement a library of iteration operators over data-structures containing functionals. From this implementation, we derive "fusion laws" that functional programmers may use to reason about the iteration operator. Finally, we show how this use of parametric polymorphism corresponds to the Schurmann, Despeyroux and Pfenning method of enforcing parametricity through modal types. We do so by using this library to give a sound and complete encoding of their calculus into System F-omega. This encoding can serve as a starting point for reasoning about higher-order structures in polymorphic languages.
引用
收藏
页码:249 / 262
页数:14
相关论文
共 31 条
  • [1] ACAR U, 2002, 30 ACMSIGPLAN SIGACT
  • [2] AMBLER S, 2002, LECT NOTES COMPUTER, V2410
  • [3] [Anonymous], 2003, Haskell 98 Language and LibrariesThe Revised Report
  • [4] BOHM C, 1985, THEOR COMPUT SCI, V39, P135, DOI 10.1016/0304-3975(85)90135-5
  • [5] Church A., 1940, The Journal of Symbolic Logic, V5, P56, DOI [DOI 10.2307/2266170, 10.2307/2266170]
  • [6] CLARKE D, 2001, UUCS200126 UTR U
  • [7] DANVY O, 1992, MATH STRUCT COMPUT S, V2, P361, DOI DOI 10.1017/S0960129500001535
  • [8] A modal analysis of staged computation
    Davies, R
    Pfenning, F
    [J]. JOURNAL OF THE ACM, 2001, 48 (03) : 555 - 604
  • [9] Despeyroux J., 2001, Mathematical Structures in Computer Science, V11, P555, DOI 10.1017/S0960129501003346
  • [10] FEGARAS L, 1996, 23 ACM SIGPLAN SIGAC, P284