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
相关论文
共 50 条
  • [1] Boxes go bananas: Encoding higher-order abstract syntax with parametric polymorphism
    Washburn, Geoffrey
    Weirich, Stephanie
    [J]. JOURNAL OF FUNCTIONAL PROGRAMMING, 2008, 18 : 87 - 140
  • [2] Parametric higher-order abstract syntax for mechanized semantics
    Chlipala, Adam
    [J]. ACM SIGPLAN NOTICES, 2008, 43 (09) : 143 - 156
  • [3] Parametric Higher-Order Abstract Syntax for Mechanized Semantics
    Chlipala, Adam
    [J]. ICFP'08: PROCEEDINGS OF THE 2008 SIGPLAN INTERNATIONAL CONFERENCE ON FUNCTIONAL PROGRAMMING, 2008, : 143 - 156
  • [4] HIGHER-ORDER ABSTRACT SYNTAX
    PFENNING, F
    ELLIOTT, C
    [J]. SIGPLAN NOTICES, 1988, 23 (07): : 199 - 208
  • [5] Focusing and higher-order abstract syntax
    Zeilberger, Noam
    [J]. ACM SIGPLAN NOTICES, 2008, 43 (01) : 359 - 369
  • [6] Focusing and Higher-Order Abstract Syntax
    Zeilberger, Noam
    [J]. POPL'08: PROCEEDINGS OF THE 35TH ANNUAL ACM SIGPLAN-SIGACT SYMPOSIUM ON PRINCIPLES OF PROGRAMMING LANGUAGES, 2008, : 359 - 369
  • [7] Primitive recursion for higher-order abstract syntax
    Schürmann, C
    Despeyroux, J
    Pfenning, F
    [J]. THEORETICAL COMPUTER SCIENCE, 2001, 266 (1-2) : 1 - 57
  • [8] Higher-Order Abstract Syntax in Isabelle/HOL
    Howe, Douglas J.
    [J]. INTERACTIVE THEOREM PROVING, PROCEEDINGS, 2010, 6172 : 481 - 484
  • [9] Primitive recursion for higher-order abstract syntax
    Despeyroux, J
    Pfenning, F
    Schurmann, C
    [J]. TYPED LAMBDA CALCULI AND APPLICATIONS, 1997, 1210 : 147 - 163
  • [10] A logic for reasoning with higher-order abstract syntax
    McDowell, R
    Miller, D
    [J]. 12TH ANNUAL IEEE SYMPOSIUM ON LOGIC IN COMPUTER SCIENCE, PROCEEDINGS, 1997, : 434 - 445