Multi-Level Languages are Generalized Arrows

نویسنده

  • Adam Megacz
چکیده

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. The converse restriction, that the host language is a subset of the guest language, is imposed for multi-stage languages – those multi-level languages with a run construct. 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 (Theorem 4.5.4). 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 (Theorem 4.7.8). This is proven formally in Coq, and the proof is offered as justification for the assertion that multi-level languages are generalized arrows. Combined with the existence of a particular kind of retraction (Definition 4.8.3) 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. Haskell is one example of a host language with the necessary kind of retraction. A modified version of GHC with multi-level terms is offered as a proof of concept; the Haskell extraction of the Coq proofs mentioned above has been compiled into this modified GHC, and is made available as a new flattening pass.

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Generalized Arrows

Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, to republish, to post on servers or to redistribute to lists, requires prior specific permission....

متن کامل

Multi-Stage Programs are Generalized Arrows

The lambda calculus, subject to typing restrictions, provides a syntax for the internal language of cartesian closed categories. This paper establishes a parallel result: staging annotations [? ], subject to named level restrictions, provide a syntax for the internal language of Freyd categories, which are known to be in bijective correspondence with Arrows. The connection is made by interpreti...

متن کامل

Hardware Design with Generalized Arrows

Instances of the GArrow type class (Figure 2) are called generalized arrows. The GArrow class generalizes Control.Arrow by allowing any type-level monoid to take the place of the cartesian product (,) and by replacing arr with the “structural” functions usually defined in terms of it. Multi-level terms with environment classifier types [TN03] may be flattened into single-level terms parameteriz...

متن کامل

A Novel Generalized Topology for Multi-level Inverter with Switched Series-parallel DC Sources (RESEARCH NOTE)

This paper presents a novel topology of single-phase multilevel inverter for low and high power applications. It consists of polarity (Level) generation circuit and H Bridge. The proposed topology can produce higher output voltage levels by connecting dc voltage sources   in series and parallel. The proposed topology utilizes minimum number of power electronic devices which helps in reduction o...

متن کامل

Modified FGP approach and MATLAB program for solving multi-level linear fractional programming problems

In this paper, we present modified fuzzy goal programming (FGP) approach and generalized MATLAB program for solving multi-level linear fractional programming problems (ML-LFPPs) based on with some major modifications in earlier FGP algorithms. In proposed modified FGP approach, solution preferences by the decision makers at each level are not considered and fuzzy goal for the decision vectors i...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:
  • CoRR

دوره abs/1007.2885  شماره 

صفحات  -

تاریخ انتشار 2010