11 research outputs found

    Solving the Expression Problem in C++, à la LMS

    Get PDF

    Programming Languages and Systems

    Full text link

    Squid: Type-Safe, Hygienic, and Reusable Quasiquotes

    Get PDF
    Quasiquotes have been shown to greatly simplify the task of metaprogramming. This is in part because they hide the data structures of the intermediate representation (IR), instead allowing metaprogrammers to use the concrete syntax of the language they manipulate. Scala has had ``syntactic'' quasiquotes for a long time, but still misses a statically-typed version like in MetaOCaml, Haskell and F#. This safer flavor of quasiquotes has been particularly useful for staging and domain-specific languages. In this paper we present Squid, a metaprogramming system for Scala that fills this gap. Squid quasiquotes are novel in three ways: they are the first statically-typed quasiquotes we know that allow code inspection (via pattern matching); they are implemented purely as a macro library, without modifications to the compiler; and they are reusable in the sense that they can manipulate different IRs. Adapting (or binding) a new IR to Squid is done simply by implementing a well-defined interface in the style of object algebras (i.e., tagless-final). We detail how Squid is implemented, leveraging the metaprogramming tools already offered by Scala, and show three application examples: the definition of a binding for a DSL in the style of LMS; a safe ANF conversion; and the introduction of type-safe, hygienic macros as an alternative to the current macro system

    Programming tools for intelligent systems

    Full text link
    Les outils de programmation sont des programmes informatiques qui aident les humains Ă  programmer des ordinateurs. Les outils sont de toutes formes et tailles, par exemple les Ă©diteurs, les compilateurs, les dĂ©bogueurs et les profileurs. Chacun de ces outils facilite une tĂąche principale dans le flux de travail de programmation qui consomme des ressources cognitives lorsqu’il est effectuĂ© manuellement. Dans cette thĂšse, nous explorons plusieurs outils qui facilitent le processus de construction de systĂšmes intelligents et qui rĂ©duisent l’effort cognitif requis pour concevoir, dĂ©velopper, tester et dĂ©ployer des systĂšmes logiciels intelligents. Tout d’abord, nous introduisons un environnement de dĂ©veloppement intĂ©grĂ© (EDI) pour la programmation d’applications Robot Operating System (ROS), appelĂ© Hatchery (Chapter 2). DeuxiĂšmement, nous dĂ©crivons Kotlin∇, un systĂšme de langage et de type pour la programmation diffĂ©renciable, un paradigme Ă©mergent dans l’apprentissage automatique (Chapter 3). TroisiĂšmement, nous proposons un nouvel algorithme pour tester automatiquement les programmes diffĂ©renciables, en nous inspirant des techniques de tests contradictoires et mĂ©tamorphiques (Chapter 4), et dĂ©montrons son efficacitĂ© empirique dans le cadre de la rĂ©gression. QuatriĂšmement, nous explorons une infrastructure de conteneurs basĂ©e sur Docker, qui permet un dĂ©ploiement reproductible des applications ROS sur la plateforme Duckietown (Chapter 5). Enfin, nous rĂ©flĂ©chissons Ă  l’état actuel des outils de programmation pour ces applications et spĂ©culons Ă  quoi pourrait ressembler la programmation de systĂšmes intelligents Ă  l’avenir (Chapter 6).Programming tools are computer programs which help humans program computers. Tools come in all shapes and forms, from editors and compilers to debuggers and profilers. Each of these tools facilitates a core task in the programming workflow which consumes cognitive resources when performed manually. In this thesis, we explore several tools that facilitate the process of building intelligent systems, and which reduce the cognitive effort required to design, develop, test and deploy intelligent software systems. First, we introduce an integrated development environment (IDE) for programming Robot Operating System (ROS) applications, called Hatchery (Chapter 2). Second, we describe Kotlin∇, a language and type system for differentiable programming, an emerging paradigm in machine learning (Chapter 3). Third, we propose a new algorithm for automatically testing differentiable programs, drawing inspiration from techniques in adversarial and metamorphic testing (Chapter 4), and demonstrate its empirical efficiency in the regression setting. Fourth, we explore a container infrastructure based on Docker, which enables reproducible deployment of ROS applications on the Duckietown platform (Chapter 5). Finally, we reflect on the current state of programming tools for these applications and speculate what intelligent systems programming might look like in the future (Chapter 6)

    Hidden Type Variables and Conditional Extension for More Expressive Generic Programs

    Full text link
    Generic object-oriented programming languages combine parametric polymorphism and nominal subtype polymorphism, thereby providing better data abstraction, greater code reuse, and fewer run-time errors. However, most generic object-oriented languages provide a straightforward combination of the two kinds of polymorphism, which prevents the expression of advanced type relationships. Furthermore, most generic object-oriented languages have a type-erasure semantics: instantiations of type parameters are not available at run time, and thus may not be used by type-dependent operations. This dissertation shows that two features, which allow the expression of many advanced type relationships, can be added to a generic object-oriented programming language without type erasure: 1. type variables that are not parameters of the class that declares them, and 2. extension that is dependent on the satisïŹability of one or more constraints. We refer to the first feature as hidden type variables and the second feature as conditional extension. Hidden type variables allow: covariance and contravariance without variance annotations or special type arguments such as wildcards; a single type to extend, and inherit methods from, infinitely many instantiations of another type; a limited capacity to augment the set of superclasses after that class is defined; and the omission of redundant type arguments. Conditional extension allows the properties of a collection type to be dependent on the properties of its element type. This dissertation describes the semantics and implementation of hidden type variables and conditional extension. A sound type system is presented. In addition, a sound and terminating type checking algorithm is presented. Although designed for the Fortress programming language, hidden type variables and conditional extension can be incorporated into other generic object-oriented languages. Many of the same problems would arise, and solutions analogous to those we present would apply

    Generalized Algebraic Data Types and Object-Oriented Programming

    No full text
    Generalized algebraic data types (GADTs) have received much attention recently in the functional programming community. They generalize the type-parameterized datatypes of ML and Haskell by permitting constructors to produce different type-instantiations of the same datatype. GADTs have a number of applications, including strongly-typed evaluators, generic pretty-printing, generic traversals and queries, and typed LR parsing. We show that existing object-oriented programming languages such as Java and C ♯ can express GADT definitions, and a large class of GADT-manipulating programs, through the use of generics, subclassing, and virtual dispatch. However, some programs can be written only through the use of redundant run-time casts. We propose a generalization of the type constraint mechanisms of C ♯ and Java to avoid the need for such casts, present a Visitor pattern for GADTs, and describe a switch construct as an alternative to virtual dispatch on datatypes. We formalize both extensions and prove a type soundness result

    Des types aux assertions logiques : preuve automatique ou assistée de propriétés sur les programmes fonctionnels.

    Get PDF
    This work studies two approaches to improve the safety of computer programs using static analysis.The first one is typing which guarantees that the evaluation of program cannot fail. The functionallanguage ML has a very rich type system and also an algorithm that infers automatically the types.We focus on its adaptation to generalized algebraic data types (GADTs). In this setting, efficientcomputation of a most general type is impossible. We propose a stratification of the language thatretain the usual characteristics of the ML fragment and make explicit the use of GADTs. The re-sulting language, MLGX, entails a burden on the programmer who must annotate its programs toomuch. A second stratum, MLGI, offers a mechanism to infer locally, in a predictable and efficient way,incomplete yet, most of the type annotations. The first part concludes on an illustration of the expres-siveness of GADTs to encode the invariants of pushdown automata used in LR parsing. The secondapproach augments the language with logic assertions that enables arbitrarily complex specificationsto be expressed. We check the compliance of the program semantics with respect to these specifica-tions thanks to a method called Hoare logic and thanks to semi-automatic computer-based proofs.The design choices permit to handle first-class functions. They are directed by an implementationwhich is illustrated by the certification of a module of trees that denote finite sets.Cette thĂšse Ă©tudie deux approches fondĂ©es sur l’analyse statique pour augmenter la sĂ»retĂ© defonctionnement et la correction des programmes informatiques.La premiĂšre approche est le typage qui permet de prouver automatiquement qu’un programmes’évalue sans Ă©chouer. Le langage fonctionnel ML possĂšde un systĂšme de type trĂšs riche et un algorithmeeffectuant une synthĂšse automatique de ces types. On s’intĂ©resse Ă  l’adaptation de cet algorithme auxtypes algĂ©briques gĂ©nĂ©ralisĂ©s (GADT), une forme restreinte des inductifs de Coq, qui ont Ă©tĂ© introduitspar Hongwei Xi en 2003.Dans ce cadre, le calcul efficace d’un type plus gĂ©nĂ©ral est impossible. On propose une stratificationqui maintient les caractĂ©ristiques habituelles sur le fragment ML et qui isole le traitement des GADTen explicitant leur utilisation. Le langage obtenu, MLGX, nĂ©cessite des annotations de type qui alour-dissent les programmes. Une seconde strate, MLGI, offre au programmeur un mĂ©canisme de synthĂšselocale, prĂ©dictible et efficace bien qu’incomplet, de la plupart de ces annotations. La premiĂšre parties’achĂšve avec une dĂ©monstration de l’expressivitĂ© des GADT pour coder les invariants des automatesĂ  pile utilisĂ©s par l’analyse syntaxique LR.La seconde approche augmente le langage de programmation par des assertions logiques permettantd’exprimer des spĂ©cifications de complexitĂ© arbitraire dans la logique d’ordre supĂ©rieur polymorphi-quement typĂ©e. On vĂ©rifie statiquement la conformitĂ© de la sĂ©mantique du programme vis-Ă -vis de cesspĂ©cifications Ă  l’aide d’une technique appelĂ©e logique de Hoare qui consiste Ă  engendrer un ensembled’obligations de preuves Ă  partir d’un programme annotĂ©. Une fois ces obligations de preuve traitĂ©es,si un programme est utilisĂ© correctement et si il renvoie une valeur alors il est certain que celle-ci estcorrecte.Habituellement, cette technique est employĂ©e sur les langages impĂ©ratifs. Avec un langage fonc-tionnel pur, les problĂšmes liĂ©s Ă  l’état de la mĂ©moire d’évanouissent tandis que l’ordre supĂ©rieur etle polymorphisme en posent de nouveaux. Nos choix de conceptions cherchent Ă  maximiser les op-portunitĂ©s d’utilisation de prouveurs automatiques en traduisant minutieusement les objets d’ordresupĂ©rieur en objets du premier ordre. Une implantation prototype du systĂšme en fournit une illustra-tion dans la preuve presque totalement automatique d’un module CAML d’arbres Ă©quilibrĂ©s dĂ©notantdes ensembles finis
    corecore