24 research outputs found
Typeful Normalization by Evaluation
We present the first typeful implementation of Normalization by Evaluation for the simply typed lambda-calculus with sums and control operators: we guarantee type preservation and eta-long (modulo commuting conversions), beta-normal forms using only Generalized Algebraic Data Types in a general-purpose programming language, here OCaml; and we account for sums and control operators with Continuation-Passing Style. First, we implement the standard NbE algorithm for the implicational fragment in a typeful way that is correct by construction. We then derive its call-by-value continuation-passing counterpart, that maps a lambda-term with sums and call/cc into a CPS term in normal form, which we express in a typed dedicated syntax. Beyond showcasing the expressive power of GADTs, we emphasize that type inference gives a smooth way to re-derive the encodings of the syntax and typing of normal forms in Continuation-Passing Style
nelli: a lightweight frontend for MLIR
Multi-Level Intermediate Representation (MLIR) is a novel compiler
infrastructure that aims to provide modular and extensible components to
facilitate building domain specific compilers. However, since MLIR models
programs at an intermediate level of abstraction, and most extant frontends are
at a very high level of abstraction, the semantics and mechanics of the
fundamental transformations available in MLIR are difficult to investigate and
employ in and of themselves. To address these challenges, we have developed
\texttt{nelli}, a lightweight, Python-embedded, domain-specific, language for
generating MLIR code. \texttt{nelli} leverages existing MLIR infrastructure to
develop Pythonic syntax and semantics for various MLIR features. We describe
\texttt{nelli}'s design goals, discuss key details of our implementation, and
demonstrate how \texttt{nelli} enables easily defining and lowering compute
kernels to diverse hardware platforms
Revisiting Language Support for Generic Programming: When Genericity Is a Core Design Goal
Context
Generic programming, as defined by Stepanov, is a methodology for writing efficient and reusable algorithms by considering only the required properties of their underlying data types and operations. Generic programming has proven to be an effective means of constructing libraries of reusable software components in languages that support it. Generics-related language design choices play a major role in how conducive generic programming is in practice.
Inquiry
Several mainstream programming languages (e.g. Java and C++) were first created without generics; features to support generic programming were added later, gradually. Much of the existing literature on supporting generic programming focuses thus on retrofitting generic programming into existing languages and identifying related implementation challenges. Is the programming experience significantly better, or different when programming with a language designed for generic programming without limitations from prior language design choices?
Approach
We examine Magnolia, a language designed to embody generic programming. Magnolia is representative of an approach to language design rooted in algebraic specifications. We repeat a well-known experiment, where we put Magnolia’s generic programming facilities under scrutiny by implementing a subset of the Boost Graph Library, and reflect on our development experience.
Knowledge
We discover that the idioms identified as key features for supporting Stepanov-style generic programming in the previous studies and work on the topic do not tell a full story. We clarify which of them are more of a means to an end, rather than fundamental features for supporting generic programming. Based on the development experience with Magnolia, we identify variadics as an additional key feature for generic programming and point out limitations and challenges of genericity by property.
Grounding
Our work uses a well-known framework for evaluating the generic programming facilities of a language from the literature to evaluate the algebraic approach through Magnolia, and we draw comparisons with well-known programming languages.
Importance
This work gives a fresh perspective on generic programming, and clarifies what are fundamental language properties and their trade-offs when considering supporting Stepanov-style generic programming. The understanding of how to set the ground for generic programming will inform future language design.publishedVersio
Modular Probabilistic Models via Algebraic Effects
Probabilistic programming languages (PPLs) allow programmers to construct
statistical models and then simulate data or perform inference over them. Many
PPLs restrict models to a particular instance of simulation or inference,
limiting their reusability. In other PPLs, models are not readily composable.
Using Haskell as the host language, we present an embedded domain specific
language based on algebraic effects, where probabilistic models are modular,
first-class, and reusable for both simulation and inference. We also
demonstrate how simulation and inference can be expressed naturally as
composable program transformations using algebraic effect handlers
Reflections on monadic lenses
Bidirectional transformations (bx) have primarily been modeled as pure functions, and do not account for the possibility of the side-effects that are available in most programming languages. Recently several formulations of bx that use monads to account for effects have been proposed, both among practitioners and in academic research. The combination of bx with effects turns out to be surprisingly subtle, leading to problems with some of these proposals and increasing the complexity of others. This paper reviews the proposals for monadic lenses to date, and offers some improved definitions, paying particular attention to the obstacles to naively adding monadic effects to existing definitions of pure bx such as lenses and symmetric lenses, and the subtleties of equivalence of symmetric bidirectional transformations in the presence of effects
Defunctionalization with Dependent Types
The defunctionalization translation that eliminates higher-order functions
from programs forms a key part of many compilers. However, defunctionalization
for dependently-typed languages has not been formally studied. We present the
first formally-specified defunctionalization translation for a
dependently-typed language and establish key metatheoretical properties such as
soundness and type preservation. The translation is suitable for incorporation
into type-preserving compilers for dependently-typed language
Reversible Term Rewriting
Essentially, in a reversible programming language, for each forward computation step from state S to state S', there exists a constructive and deterministic method to go backwards from state S' to state S. Besides its theoretical interest, reversible computation is a fundamental concept which is relevant in many different areas like cellular automata, bidirectional program transformation, or quantum computing, to name a few. In this paper, we focus on term rewriting, a computation model that underlies most rule-based programming languages. In general, term rewriting is not reversible, even for injective functions; namely, given a rewrite step t1 -> t2, we do not always have a decidable and deterministic method to get t1 from t2. Here, we introduce a conservative extension of term rewriting that becomes reversible. Furthermore, we also define a transformation to make a rewrite system reversible using standard term rewriting.This work has been partially supported by the EU (FEDER) and the Spanish Ministerio de EconomÃa y Competitividad (MINECO) under grant TIN2013-44742-C4-1-R, by the Generalitat Valenciana under grant PROMETEO-II/2015/013 (SmartLogic) and by the COST Action IC 1405 on Reversible Computation. A. Palacios was partially supported by the the EU (FEDER) and the Spanish Ayudas para contratos predoctorales para la formación de doctores de la Sec. Estado de Investigación, Desarrollo e Innovación del MINECO under FPI grant BES-2014-069749. Part of this research was done while the second and third authors were visiting Nagoya University; they gratefully acknowledge their hospitality.Nishida, N.; Palacios Corella, A.; Vidal Oriola, GF.; Nishida (2016). Reversible Term Rewriting. Schloss Dagstuhl-Leibniz-Zentrum für Informatik GmbH, Dagstuhl Publishing. https://doi.org/10.4230/LIPIcs.FSCD.2016.28