HackerPapers

arXiv:1007.2885cs.PL

Multi-Level Languages are Generalized Arrows

Adam Megacz

Abstract

Multi-level languages and Arrows both facilitate metaprogramming, the act of writing a program which generates a program. The arr function required of all Arrows turns arbitrary host language expressions into guest language expressions; because of this, Arrows may be used for metaprogramming only when the guest language is a superset of the host language. This restriction is also present in multi-level languages which offer unlimited cross-level persistence. <p> This paper introduces generalized arrows and proves that they generalize Arrows in the following sense: every Arrow in a programming language arises from a generalized arrow with that language's term category as its codomain. Generalized arrows impose no containment relationship between the guest language and host language; they facilitate heterogeneous metaprogramming. The category having all generalized arrows as its morphisms and the category having all multi-level languages as its morphisms are isomorphic categories. This is proven formally in Coq, and the proof is offered as justification for the assertion that multi-level languages are generalized arrows. <p> Combined with the existence of a particular kind of retraction in the host language, this proof can be used to define an invertible translation from two-level terms to one-level terms parameterized by a generalized arrow instance. This is ergonomically significant: it lets guest language providers write generalized arrow instances while the users of those guest languages write multi-level terms. This is beneficial because implementing a generalized arrow instance is easier than modifying a compiler, whereas writing two-level terms is easier than manipulating generalized arrow terms.

arXiv comments
12 pages
Journal reference
DOI
Subjects
cs.PLProgramming Languages math.CTCategory Theory

On Hacker News

Linked by 2 identifiable commenters in 2 comments across 2 threads, from May 2020 to Dec 2021. Found in 1 HN submission from Jan 2020 to Jan 2020. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments2 threads

    • The problem with this is this is that it assumes the programming language is the last world in the developer experience. I am certainly a language person, and you cannot get anywhere with a bad language, but merely having a good language is not enough. Working on…

      Ericson2314View on HNParent context

    • I haven't read all the way through yet but this seems pretty great. Some rough edges, sure, but it's accessible, fairly comprehensive, and concise. Have you seen "Multi-Level Languages are Generalized Arrows" by Adam Megacz? https://arxiv.org/abs/1007.2885

      carapaceView on HNParent context

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.