Skip to main content
    • Aa
    • Aa
  • Get access
    Check if you have access via personal or institutional login
  • Cited by 3
  • Cited by
    This article has been cited by the following publications. This list is generated based on data provided by CrossRef.

    Bahr, Patrick and Hvitved, Tom 2012. Parametric Compositional Data Types. Electronic Proceedings in Theoretical Computer Science, Vol. 76, p. 3.

    Felty, Amy and Momigliano, Alberto 2012. Hybrid. Journal of Automated Reasoning, Vol. 48, Issue. 1, p. 43.

    CARETTE, JACQUES KISELYOV, OLEG and SHAN, CHUNG-CHIEH 2009. Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages. Journal of Functional Programming, Vol. 19, Issue. 05, p. 509.


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

  • DOI:
  • Published online: 01 January 2008

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 data type, one must either simultaneously define an inverse operation (which may not exist) or show that all functions embedded in the data type 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 Schürmann, 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 . This encoding can serve as a starting point for reasoning about higher-order structures in polymorphic languages.

Linked references
Hide All

This list contains references from the content that can be linked to their source. For a full set of references and notes please see the PDF or HTML where available.

S. Ambler , R. L. Crole & A. Momigliano (2002) Combining higher order abstract syntax with tactical theorem proving and (co)induction. In 15th International Conference on Theorem Proving in Higher Order Logics. Lecture Notes in Computer Science, vol. 2410. Hampton, VA: Springer.

H. Bekić (1984) Definable operation in general algebras, and the theory of automata and flowcharts. Programming Languages and Their Definition. Springer-Verlag. LNCS vol. 177.

C. Böhm & A. Berarducci (1985) Automatic synthesis of typed Λ-programs on term algebras. Theor. Comput. Sci. 39, 135154.

R. Davies & F. Pfenning (2001) A modal analysis of staged computation. J. ACM, 48 (3), 555604.

J. Despeyroux , A. P. Felty & A. Hirschowitz (1995) Higher-order abstract syntax in Coq. In Second International Conference on Typed Lambda Calculi and Applications. London, UK: Springer-Verlag.

L. Fegaras & T. Sheard (1996) Revisiting catamorphisms over data types with embedded functions (or, programs from outer space). In 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. St. Petersburg Beach, FL: ACM Press.

J.-Y. Girard (1971) Une extension de l'interprétation de Gödel à l'analyse, et son application à l'élimination de coupures dans l'analyse et la théorie des types. In J. E. Fenstad (ed), Second Scandinavian Logic Symposium. North-Holland Publishing Co.

R. Hinze (2002) Polytypic values possess polykinded types. Sci. Computer Programming, 43 (2–3), 129159. MPC Special Issue.

P. Johann (2002) A generalization of short-cut fution and its correctness proof. Higher-order Symbolic Comput. 15, 273300.

E. Meijer , M. M. Fokkinga & R. Paterson (1991) Functional programming with bananas, lenses, envelopes and barbed wire. In Conference on Functional Programming Languages and Computer Architecture. Cambridge, MA: Springer-Verlag.

D. Miller & A. Tiu (2005) A proof theory for generic judgments. ACM Trans. Computat. Logic. 6 (4), 749783.

A. Nanevski (2002) Meta-programming with names and necessity. In Seventh ACM SIGPLAN International Conference on Functional Programming. ACM Press, pp. 206217.

A. M. Pitts & M. J. Gabbay (2000) A metalanguage for programming with bound names modulo renaming. In Mathematics of Program Construction. Port de Lima, Portugal: Springer-Verlag.

C. Schürmann , J. Despeyroux & F. Pfenning (2001) Primitive recursion for higher-order abstract syntax. Theor. Comput. Sci. 266 (1–2), 158.

E. Sumii & N. Kobayashi (2001) A hybrid approach to online and offline partial evaluation. Higher-order Symbol. Comput. 14 (2/3), 101142.

V. Trifonov , B. Saha & Z. Shao (2000) Fully reflexive intensional type analysis. Fifth ACM SIGPLAN International Conference on Functional Programming. Montreal, Quebec, Canada: ACM Press. Extended version is YALEU/DCS/TR-1194.

G. Washburn & S. Weirich (2003) Boxes go bananas: Encoding higher-order abstract syntax with parametric polymorphism. In Eighth ACM SIGPLAN International Conference on Functional Programming. Uppsala, Sweden: ACM Press, for ACM SIGPLAN.

H. Xi , C. Chen & G. Chen (2003) Guarded recursive data type constructors. In 30th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. New Orleans, LA: ACM Press.

Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Journal of Functional Programming
  • ISSN: 0956-7968
  • EISSN: 1469-7653
  • URL: /core/journals/journal-of-functional-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *